How to set a cookie in client side a acces that in server side?


I have used  [document.cookie = 'nav=another test; expires=Fri, 3 Aug 2009 20:47:11 UTC; path=/' ] the code enclosed in bracket to set the cookie in the client side. However if i try to access the same in the code file, the value comes as blank.

 Please guide me how to set it in client side and access in server side.

12/30/2008 12:21:10 PM 8807 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 43

 To write -

        HttpCookie cookie = Request.Cookies["Language"];
        if (cookie == null)
            cookie = new HttpCookie("Language");

        cookie["lang"] = "Arabic";
        cookie.Expires = DateTime.Now.AddYears(1);

To read - 

       HttpCookie cookie = Request.Cookies["UaeLpLanguage"];
        string pageUrl = Request.Url.ToString();
        if (cookie != null)
            if (cookie.Value.ToString() == "English")

              // ur operation

Hope it helps.


If this post is useful to you, please mark it as answer.
12/30/2008 2:09:05 PM

 You Should be able to access it on the server side.. Make sure you are trying to read the Request collection, not the Response cookie collection.. For example, the cookie you mentioned can be read and printed as,


Kumar Reddi
12/30/2008 2:10:09 PM

Similar Artilces:

Firing both Client side event and server side event for server side button
I am having some difficulties getting this to work.. I have button_click ( and ClientClick (Javascript).  Javascript is firing fine.  Server script is not. may be you have return return false in the in the javascript which is why its not firing server side event.You should add javascript evelt like thisbutton1.onclientclick = "functionname" Function should nopt return false. Vikram www.vikramlakhotia.comPlease mark the answer if it helped you...

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in ( required field, range validator and others) question is the required field validator is a server side control. So does that mean that it does a post back? it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

why we say that cookies are only on client side and session on server side?
 Hello,I have a very basic question. It is said that the cookies are on the client side only which I agree is true,  but during form authentication when we identify that the user is a valid user. After that with every request the user makes a cookie is sent to the server, then what on the server side identify that the user is a valid user? It does means that there is some kind of session on the server side also? Can you make it clear. Thanks. The cookie is the artifact used to maintain a session. It is exchanged between client and server, so it's a bidirectional...

Jscript, moving from client-side to server-side (.NET)
Hey all I’m working translating a web-app written in client-side Jscript to run on the server-side as JScript.NET. Without needing to get too specific, I am using Jscript because the original page aggregated raw data to produce statistical results (this was done dynamically based on user 'sort-by' options). The final output is an html report that can be emailed. Because this is currently being done on the client side, as the raw data grows the load-time grows as well (to the point that has almost become unusable). I’m posting here to see if anyone has any experi...

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

How to read cookies value on client side from server side code?
 I read an article which explains on how to read the client side cookies from C# code by doing something like://Grab the cookie 9: HttpCookie cookie = Request.Cookies[strCookieName];I am very confused here. Server side code in on the server side, so how can a server side code read the cookies on the client machine?I thought that only a client side script like Java Script  can read the client side cookies.Kindly explain...please.thanks.   Each time you request a page on a domain, the browser looks for a cookie for that domain on the client machine if it exists then it ...

How can I set client side values as server side values?
Hi, Can anyone tell me how I can get client side values such as document.referrer, navigator.appName etc... into server side scripts? There are some client side values I'd like to set as session vars and insert into the db? How do I go about this? Thanks for any pointers Davlon PS (I'm using powersite Pass them as page parameters, e.g., http://myserver/myurl?document.referrer=whatever&navigator.appName=yadayada Then, in your server-side script, just loop through the document.value array and get these values. -- pbm_hopethishelps, Roy Kie...

Server Side or Client Side
Hi I'm a bit confused about this whole server side / client side thing. Are applets, embeded objects consider client side? If I have a form within my aspx page which connects to a database on the server side what is it considered? If I have some business logic written within a VB file when the client access the functions within that business logic (for example some kind of validation function) does the client browser actually downloads that VB file? Can someone suggest how to differentiate between client side and server side components within a based website?  Hi, i can&#...

Client side and server side
We have a application, where we have some validation on the clientside using EnableClientSideValidation. If you don't have fullscreen you can't see some of the error-messages. What we want is to jump to the place on the page where the message is displayed. One problem is that the button is a serverbutton (runat="server"). How can we accomplish this on the clientside using the same button. I have tried to use "onClientClick" and a link something like this:   <A HREF=>form<...

What is Client Side and Server Side?
I am New of ASP.Net What we can and should do client side and Server Side? What uses? Please any one clear my doubt. Thanking YouEndendrum Priyamudan P m R Clientside is basically what a person can see and serverside is where actions get processed. that's kinda simply puyt but thats the deal, you code serverside, and the html and javascript it generates let's the users for example click a button, then serverside you have coded what should happen when a button gets clicked for example turn text red. Then the server sends a new page with red text to the client (clientside...

Server-side or Client-side
In general, I'm wondering if there are any criteria to use when choosing between using a client side element or a server side element. For example, if I'm going to put an HTML table on a page, how do I decide whether or not to use a server control?  Should the server side always be chosen or if there is not explicit server side functionality required is it better to opt for a "normal" client side table? Obviously, if there is a need for server side control the question is answered, I'm looking more at more ambiguous situations. Thanks  This is from Micros...

communication between client side(java script) and server side in .net project
I have a question which is, when building a .net project, we are able to use server side code and client side code(java script). How do they communicate? Thanks Client Side coding works with the WebBrowser. So when ever you write client side code you have to keep browser compatability in your mind and you have to code. Server Side code works with Web Server (IIS) and it's ASPNET ISAPI's. The won't directly communicate with each other. But using AJAX you can all server side code from Client Side! Example article on Ajax@ Thanks, May I say, when an user clicks a button, pop up box show up. are they communicate? When User Clicks on Button, a popup comming means, on that Button onclick event you might have some Client Side JavaScript. That's why you got popup. So are they communicate? As Browser will act for onclick event, message box shows up. Is click and Sever on sommunicating for this. No it's puerly client side event. But some times, when you click button it submitts to server and does some process as you needed and get's the results back, in that instance you can think browser send request to server and server process it and responds back to browser. hope I made it clear to you!  Sreedharhttp://www.w3coder.orgweblog

client-side and server-side?
hi, can someone tells me how diff is client side and server side are these two? When I tried to do validation ... I would use Javascript ... which has something like: document.forms[0] ... I think that's client side. My understanding on server side is the "form" ... like u will have <form action=".." method=post> ..... </form> ... so it will send to server ... am I on the right track? Are there any other type of server side examples? Hi, ASP.NET itself is server side. Every piece of code processed is done on a server. What comes out of this is sent to the browser (client). This contains rendered html en can contain client side javascript, css, ... Client and server side are two completely different things but if you let them cooperate, both on their side, you can create wonderful things. Take a look at this site for more information and some lessons because it seems to me that you are in need of some eduction about web technology: w3schools. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons....

textbox value set on client side, is not visible on server side or, on the source of the page.
hi, I have a textbox on my webform. the first time I load my page I fill this textbox with  "name" on the server side. once the page is loaded I set the value of the textbox to "thisIsme" with client side code. I even see a different text in the texbox. client side:document.all('txtnameInput').value =  'thisIsme'; server side:Me.txtnaam.Text 'is stil "name" and not "thisIsme" Why is this happening? on the webpage I see the text "thisIsme", but when I look at the source of the webpage I still see the old value in it. it's very odd... I am NOT setting the value back to "name" on the page load event of the postback. any idea's why this is happening ?see my blog at and check the future of open mobile widget solutions at When you look at the "source code" of a web page, you see the HTML which was originally sent from the server, if you change any value inside any element on client side (textboxes, selects, checkboxes...) you won't see it on the "source code", but the "page" object into the browser does keep them well. Now if you don't get the rigth value ("thisIsme") when you submit the form back to the server that could be a different issue....

How to add multiple new row in a Gridview in the client side(through javascript) and acces them in Server side
 HI,I want to add a new row in the grid view in the client side. The user can add as many rows as he want. He will save all the new data at one time. The functionality is somewhat similar to the add attachment in Gmail. I want the user to be able to add multiple rows in the client side and then click on save which save all the data. If any one can provide code it will be helpful.Vikram www.vikramlakhotia.comPlease mark the answer if it helped you One way to solve this easy is to use ASP.Net AJAX's UpdatePanel and make sure the server-side add the new row for you. You can store the...

Access client-sde set cookies from server-side code behind
Hi there,I found another post relating to this topic but no one gave any example code, everyone just said: "yes, you can access cookies that you set client side (using javascript) from the code-behind, server side".My situation is this:I have an external web application making a call to one of the pages in my application . It passes a variable via the query string.This external site is requested a restricted resource and thus users must sign in before continuing.So that it makes a little more sense, I have coded the requested page to recognise calls from the external application (t...

Client side or server side validation???
I have multiple usercontrols each displayed by pressing a button and then change the apperance to a new user control and so on. I have to check that almost every field in this user controls have a value entered, and then indicate (e.g. with a red star) those textboxes that does'nt have a value entered. How should I do this in the best way, client side or server side with some validator? I have in mind that when using a server side validator, it may dissapear when making a postback. But I'm not sure, and I assume there is a way to come around this problem?What do you all say? Client side or server side validation in my case, and why?Thanks in advance!// Carl Both.You should always validate client side where possible for performance reasons.You should always validate server side for performance and security reasons.RegardsDave Ok! But where should I "mark" the field who doesn't have a value? Client or server side? And I want it to persist postbacks.But why using both validations? Can you explain that further?Should I use javascript for client side validation and RequiredFieldValidator for server side validation? Or do you have some other suggestion? If you are just checking for blank values I would suggest using client side validation, however; if you need to check against a value in a database, server side is the most secure.I believe the RequiredFieldValidator automatically generates javascript code if you are just checking for blank values. The Validator web contro...

Client side vs Server side
I have a button on a web form that when clicked executes the code in the _click procedure.  However, if I have a statement in the _click procedure that (lets just say) sets a label visible, this action is not shown until the procedure has finished and control is returned back to the form. This I assume is because the _click procedure is a server side function?   Conversely java script is on the client side and would show immediate results?  Are these my only options? Is there anything I can do in a _click event that would allow other labels, buttons et...

server side or client side page?
a page that contain a validation control and starting a storeProcedures when the user click on a button --is considered as a client side page or as a server side page?it seems to me that in everthing is server side, where are the client side pages?thanks The sp is server side, but the validation can be on or the other, depending on how it's coded.ASP.Net has it's validations, so it's server side when using them.But you can also make validations via JavaScript, so that would be client side.Zath but the validation controls (like RequiredFiledValidator) is a client side va...

Server-Side vs Client-Side ?
I am kind of newbie on "Atlas". Most of my work now are doing with updatepanel and other related controls, not any client script. However, i really want to know - what is the real power of the "Atlas" Client-Side ? Is that the same as UpdatePanel Server-Side control ?  What make these control different and in which way ? Thank you Hi,you can do much more than UpdatePanel stuff. You can do Javascript OOP, use client side templated controls, databinding, create animations and other visual effects, develop gadgets for, create extenders for ASP.NET server controls...My suggestion is to take a tour of the quickstarts if you haven't explored them; you can also give a look at my mashup (url is in the signature, you can dowload the source) and you'll found some demos in my blog (for example, about drag and drop).Alessandro Gallo | Blog | My book: ASP.NET AJAX In Action Dear. Garbin Is that the same as Atlas toolkit ? If you are using ASP.NET today, or want to add AJAX-style interactivity to a web app using ASP.NET, use the UpdatePanel and control extenders in Atlas. These allow you to enrich a web site with AJAX techniques without learning or writing client-side script. For more elaborate AJAX apps, use the client-centric programming model in the Atlas client script framework. With this framework, you'll need to develop in Javascript, but Atlas contains a rich framework to let you be more productive. The Atlas server controls render this client script on...

Is the ViewState server side or client side?
 Hello,I read on the articel that ViewState is only on the client side, but then I saw a code where the ViewState was also used on the server side like the following:String Name = ViewState["Name"]; So that meand that the ViewStae is also availabel on the server side?Kindly explain.Thanks ViewState is held in a hidden field in the page and just like any control in the page you can access and use its value in server side code. To quote Dave Reed... "Viewstate is a very misunderstood animal" :-)To truly understand ViewState, go through..

when to use client side / server side?
Hey, Please can someone tell me when do i need to use a client-side or a server-side? For instance, I have a dropdownlist and when the user choses one of the listitems then click on the button to submit changes,i need first to validate the new value chosen by the user by comparing it with the old value and then redirect the user to the next page if there are no errors or view an error on the other hand! so in this case what's more preferable to use a JScript (client side) or on the click event of the button pressed (server side)! waiting the reply................. thanx in adva...

Server Side versus Client Side ?
Good day to all those that can assist me.  My name is Greg and I am sort of new to ASP and  I am however not new to programming in ohter languages.  I have a couple web pages I wrote that obtain information from the user and based on what specific information the user selects it will run a WScript and OShell telnet script I wrote when the user clicks on a button.  If I run this from my computer, running 2003 server,  using Visual Web Developer 2008 Express debugging (F5) feature, which launches a local browser, the program and WScript runs per...

Validations client side or server side ???
Where should the validations (Required field, range, etc.) be done in an web page client side or server side?  As per my knowledge most of the validations are on client side using javascript, unfortunately it won't work if someone has disabled their browsers javascript option. what do we do in this case? Any suggestion please. Both... Client-side for rich client experience. Server-side for data validation and for clients who have disabled javascript. *Always* validate on the server side. You will still get the benefits of client-side validation on browsers setup to handle th...

Web resources about - How to set a cookie in client side a acces that in server side? -

Cookie dough - Wikipedia, the free encyclopedia
Cookie dough refers to a blend of cookie ingredients which has been mixed into a malleable form which has not yet been hardened by heat . The ...

Facebook’s 2014 Game of the Year: Cookie Jam
C is for cookie, and it also stands for champion, as Cookie Jam from developer SGN was named “2014 Game of the Year” by Facebook. (more…) New ...

Tastemade - Cookie the News: David Bowie - Facebook
"I don't know where I'm going from here, but I promise it won't be boring." - David Bowie, 1947-2016

Facebook’s cookie-free targeting with Atlas: one step closer to Minority Report?
... movement another notch with the recent re-launch of Atlas , which boasts, amongst other things, the ability to target audiences without cookies. ...

Alasdair Cookie (@AlasdairStuart) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

How Proud Girl Scout Dad Chris Rock Got the Oscar Cookie Sale Started
The Girl Scouts selling cookies at the Oscars was indeed a real proud papa moment. During Sunday night's Academy Awards, host Chris Rock took ...

How Chris Rock Turned Girl Scout Cookies Into the Oscars' Biggest Brand Winner
... one expected that he would engineer the night's biggest, and sweetest, brand spotlight for one of the most high-profile Girl Scout cookie sales ...

Chris Rock raised $65K selling Girl Scout cookies for his daughters during the Oscars
Chris Rock sold $65,243 worth of Girl Scout Cookies during Sunday night's Oscars, hitting up his famous friends in the audience in order to help ...

Cops: Siblings robbed Girl Scout selling cookies
The Florida brother and sister duo allegedly stole a box of money from the table where a 12-year-old was selling the popular cookies outside ...

Resources last updated: 3/11/2016 5:39:44 PM