I want to use session object in my web app.I want to store some cookies too(Some custom informations) .How can i use both without the URL not being modified like
http://www.example.com/(S(lit3py55t21z5v55vlm25s55))/orderform.aspx
In my ASP.NET page,
I am setting some session variable
Session["customerId"]="Some name";
Then i am trying to set some value in cookie
HttpCookie objCookie = new HttpCookie("vendorName");
Response.Cookies.Clear();
Response.Cookies.Add(objCookie);
objCookie.Values.Add(cookiename, "ATT");
DateTime dtExpiry = DateTime.Now.AddDays(2);
Response.Cookies[cookiename].Expires = dtExpiry;
In this page now i can access the sesion variable values,But when i m being Redirected to another asp.net page, I am not getting my session values there.Its seems like Its being lossed.
Any idea how to solve this. I want both session and cookies
I think your problem may be this
If you clear all the cookies, you will be clearing the cookie that ASP.Net uses to store the session identifier. Without that cookie ASP.Net can’t hook up the users Session with subsequent requests and so the Session will be lost.