ASP.NET Cookies

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good Day Folks,

Never had cookie problems with ASP but ASP.NET is a different story.

I'm getting the following error when writting a cookie. How do I get around
this ?

Thanks in advance
/Serge

Value of type 'String' cannot be converted to 'System.Web.HttpCookie'.

Response.Cookies.Add("OracleLogin")("blackboard") = "welcome"
--
 
Serge,
Response.Cookies.Add() expects HttpCookie object.You are trying to
pass string .That is the problem.
Construct HttpCookie objct and pass to cookie's add class.
(ex)
HttpCookie cookie = new HttpCookie("Cookiename",cookievalue);
 
Hi Serge,

Try the following :

private void Button2_Click(object sender, System.EventArgs e)
{
System.Web.HttpCookie cookie = new HttpCookie("CookieName","MyValue");
Response.Cookies.Add(cookie);
}

private void Button3_Click(object sender, System.EventArgs e)
{
System.Web.HttpCookie cookie = Request.Cookies.Get("CookieName");
System.Diagnostics.Debug.WriteLine( cookie.Value );
}

Bye,
 
Back
Top