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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top