I am trying to perform site login using values from a cookie, but for some
weird reason the cookie is being destroyed after the browser window is
closed. I checked the browser settings for the cookies, and there is nothing
there that terminates cookies uopn browser close. The following is a sample
of the code I am runinng:
To write the cookie:
This code runs if the user is not logged on the site and the cookie does not
exist.
writeCookie(str ing user, string password)
{
try
{
HttpCookie loginCookie = new HttpCookie(cook ieName);
Response.Cookie s.Clear();
Response.Cookie s.Add(loginCook ie);
loginCookie.Val ues.Add(cookieN ame, user + " " + password);
}
catch
{
}
}
The code to retrieve the cookie does so by getting the value of the cookie
and login on the user. I get the value of the cookie this way:
cookieValue = Request.Cookies[cookieName].Value;
The whole t hing is that this code is on the onLoad event of the form. It's
supposed to get the values of the cookie, but I get a null reference
exception because the cookie does not exist even though I wrote it with the
code above.
Can anyone help?
HS