ASP.NET cookies for ASP page
I have a wierd situation where I have an ASP.NET page that sends the user to the ASP page, and data is passed from one to开发者_如何学运维 the other via query string.
I've been assigned the task of changing this so that cookies are used instead of query strings.
I'm a little clueless here. Is this possible? How do I get started? Do I need to worry about anything special because one page is ASP.NET and the other ASP ? I also cannot be totally reliant on Javascript because of those once-in-a-while user visitors who have Javascript turned off.
This is pretty simple. As long as you are not setting a 'Session Cookie', the cookie is set on the browser.
I'm doing it here...when the user logs in and wants me to remember his username:
Set the cookie in ASP.NET:
Response.Cookies.Add(new HttpCookie("RememberMeUserName", owner.Username));
View the value in ASP:
Response.Write(Request.Cookies("RememberMeUserName"))
Both the ASP.NET & ASP pages must be on the same domain name.
Ed B seems to have it - further reading available here:
http://ryangaraygay.com/blog/post/Updating-ASP-cookie-from-ASPNET-vice-versa.aspx
I also found this : http://www.eggheadcafe.com/tutorials/aspnet/198ce250-59da-4388-89e5-fce33d725aa7/aspnet-cookies-faq.aspx
With gotcha's concerning IE 6 and fixes! Also has information on how to store multiple values in them.
精彩评论