Browser confirms that both curvlist
and guestuser
cookies exist. However When I get the guestuser
it has the correct value:
string Guest = Request.Cookies["guestuser"];
but the cookie curvlist
is empty:
The only difference is that guestuser
is created in server side, but curvlist
created by javascript. But it has nothing to to with reading the cookies
Experimenting different values for the cookie, I found out something that is very stupid (correct me if I'm wrong): Apparently cookie name and value is separated by comma so having commas in the value would lead loss of the rest of the value after comma (in my case starting with comma would lead to empty value). I changed the separator in cookie to $
instead of ,
and now I'm getting the correct value.
But why Asp.net reads cookies this way? (Note that there was no problem when reading cookies with comma separated values in the javascript .
CookieManager : ASP.Net Core Abstraction layer on top of HTTP Cookie . ASP.NET Core Wrapper to read and write the cookie. it has fluent apis and ease of use.
https://github.com/nemi-chand/CookieManager
Silent features:
Have a look
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.