Cookies and Code-Behind?

  • Thread starter Thread starter Jack
  • Start date Start date
J

Jack

Hello,

Will Cookies work in a code-behind aspx and aspx.vb page?

I am trying to set a cookie on one page and the read it on another page.

If anyone can help, let me know.

Thanks in advance for your time,

Jack
 
Jack said:
Hello,

Will Cookies work in a code-behind aspx and aspx.vb page?

I am trying to set a cookie on one page and the read it on another page.

If anyone can help, let me know.

Thanks in advance for your time,

Jack
Jack,

Cookies will work just fine in web forms that use code behind. Take care
though to check for null values before attempting to read a cookie.

e.g.

if(Request.Cookies["Visited"] != null) {
string theCookie = Request.Cookies["Visited"];
}
else {
Request.Cookies["Visited"] = "MyCookieValue";
}

Apologies for the C# but my VB is rusty though I think you should get
the general idea.

HTH
Kev
 
Back
Top