vb.net - How to prevent publish resetting cookies using ASP.NET? -
i have web site uses cookies using asp.net, everytime publish new site , upload or of new .dlls invalidates existing cookies.
cookies used track simple logins, want maintain cookies created before publish still usable afterwards - seems affect webkit based browsers , in testing can replicate issue after each partial or full publish.
below code use set cookie:
if httpcontext.current.response.cookies(cookie_name) nothing dim _cookie new httpcookie(cookie_name, cookievalue) _cookie.path = cookie_path _cookie.expires = cookie_expires httpcontext.current.response.cookies.add(_cookie) else httpcontext.current.response.cookies(cookie_name) .path = cookie_path .value = value .expires = cookie_expires end end if
and here code use read cookie:
if httpcontext.current.request.cookies(cookie_name) isnot nothing return httpcontext.current.request.cookies(cookie_name).value end if
where cookie_name set "mycookie" , cookie_path set "/" , cookie_expires set "#1/1/2035#"
i can read / write cookies fine, once publish created cookies become unreadable webkit browsers, although can written again, i'm not sure case time - want publish have no effect on cookies @ - possible?
make sure have defined machine key in web.config. otherwise viewstate, session, forms authentication, or other encrypted and/or secured values invalidated when app recycles.
here article on codeplex.
this online tool generates machine key you.
<system.web> <machinekey values here/> </system.web>
Comments
Post a Comment