I am not sure why this happens. In the same program i am using sessions which has worked. Now i am trying to make my site compatible when the user does not send cookies (which should be simple). I wrote
long userId, loginId;
//...
//put data into cookies
HttpContext.Current.Session.Add("userId", userId.ToString());
HttpContext.Current.Session.Add("loginId", loginId.ToString());
and i see that they are null in this statement
var cookies = HttpContext.Current.Request.Cookies;
long mUserId;
string u, id;
if (cookies["userId"] == null)
{
//these are null
u = (string)HttpContext.Current.Session["userId"];
id = (string)HttpContext.Current.Session["loginId"];
}
In both cases (working and not working) after i set the session i call
HttpContext.Current.Response.Redirect("someUrl");`