ASP.NET 2.0 Cookies

D

David R.

I'm writing my own login dialog and want to store the user's info in a
cookie (for the "remember login" option). Somehow when I try to retrieve
the cookie, it keeps telling me it's null. What am I doing wrong?

From login page:

Response.Cookies["RememberMe"].Value = "Y";



From mainmenu page:

if (Request.Cookies["RememberMe"] == null)
{
// go to login page
}
else
{
if(Request.Cookies["RememberMe"].Value.ToString() == "Y")
{
// welcome back...
}
}
 
G

Guest

Cookie needs to have an expiration date in the future or it becomes an
in-memory only cookie. Create an HttpCookie object first, give it an
expiration, then add to Cookies collection.
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,229
Latest member
GloryAngul

Latest Threads

Top