TheCommunicator
asked on
Cookie expiration fails
I have this line of code:
I suppose it has to add 20 minutes to the cookie which resides on the client.
Now, if I do something like this:
what should be Rcookie's expiration? Ithought it would be something 20 minutes after from when I saved "Currentuser" cookie.
BUT
it shows me {1/1/0001 12:00:00 AM} what does that even mean?
Request.Cookies["CurrentUser"].Expires = DateTime.Now.AddMinutes(20);
I suppose it has to add 20 minutes to the cookie which resides on the client.
Now, if I do something like this:
RCookie = Request.Cookies["CurrentUser"];
what should be Rcookie's expiration? Ithought it would be something 20 minutes after from when I saved "Currentuser" cookie.
BUT
it shows me {1/1/0001 12:00:00 AM} what does that even mean?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok Guys, may be my little lack of Web architecture also playing a major role here but just for the sake of the question when I do something like this:
Server is requesting a Cookie with the name "CurrentUser" and using it to instantiate a local instance called cookieCurrentUser. Right?
So, would that be a correct statement that cookieCurrentUser gets everything from the client except expiration date?
HttpCookie cookieCurrentUser = Request.Cookies["CurrentUser"]
Server is requesting a Cookie with the name "CurrentUser" and using it to instantiate a local instance called cookieCurrentUser. Right?
So, would that be a correct statement that cookieCurrentUser gets everything from the client except expiration date?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
To conclude: When server asks for Cookie, Web Browser is not capable of sending Expiration date/time, it only sends name/value at this moment. and when Cookie is received by the server, it sets default to some 01/01/001 date.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks :).
http://www.codeproject.com/KB/aspnet/aspnetcookies.aspx
I hope this helps.