Chris Ara
11-09-2006, 06:15 PM
Hello , people
I'm trying to use a cookie to store information about users logged into an application. Everytime I ask for the cookies value it returns nothing. I've tryed giving the cookie a new value and saving it using Response.Cookies.Add("myCookie") . When I get the cookie after saving it the value is null. Does anyone know why this is happening.
wayneph
11-10-2006, 07:57 AM
how are you creating the cookie? and are you using Classic ASP or .NET? Using them is a little different in each environment.
Chris Ara
11-10-2006, 02:56 PM
I've used .net previously to make cookies and had zero problems , visual basic .net 2003 asp web application to be exact. I recently downloaded visual web developer 2005 express. Which basically only creates asp applications and web applications. I used the same code from the 2003 in the newer 2005 and it doesn't work. Here is what I am using.
'create a cookie
Dim CookieSignedIn As New HttpCookie("SignedIn")
'set the value to signed in
CookieSignedIn.Value = "Signed In"
'set the expiration date
CookieSignedIn.Expires = DateTime.Now.AddDays(1)
'add to cookies
Response.Cookies.Add(CookieSignedIn)
this code I use to create the cookie
Dim CookieSignIn As HttpCookie = Request.Cookies("SignedIn")
TextBoxName.Text = CookieSignIn.Value
and here I get the cookie and the value
the problem is the cookie is there I've tested that using the request.cookie method , but the cookie had no value when I retreive it.
help me if you can. my coding looks correct.
thanks
wayneph
11-13-2006, 10:17 AM
Are you trying to use it in the same request that you created it in? Or in a trip back to the server? I haven't used cookies a lot, but I can see a scenario where the cookie won't be in the Request Collection until you do a full round trip to the client.
Chris Ara
11-14-2006, 03:08 AM
Yep I've tried puttting it in a button click event in the log on page. I still have the same problem though the cookie is there but it will have no value. I think this is an asp .net 2.0 problem I never had so many problems with 1.0 , If you think of anything help me out please.