ASP.NET gets the solution for setting cookies less than JS

  • 2020-05-12 02:26:26
  • OfStack

Adding "path= expiration time "to the js method solves this problem.

For example: // write cookies
 
function setCookie(name,value) 
{ 
document.cookie = name "=" escape (value) ";path=/"; // Set up the cookie Close browsing is invalid  
} 

I've added 1 more path=/, and I'm done. It's that simple.

The Path property of Cookie is set here. The Path="/" property must be set on both the client side and the server side in order for js and ASP.NET to interact with Cookie! The other one is the encoding problem, where the encoding in JS is encodeURI for ASP.NET for Server.URLEncode.

Related articles: