HttpCookie.Domain property

  • Thread starter Thread starter ulabala
  • Start date Start date
U

ulabala

I was trying to retrieve the cookie collection and display the domain
to which those cookies were written to, but I always see a NULL value
for the domain property. Can anyone shed some light?
This is in Framework 2.0.
 
Yes I am. I can see the name and value but not the domain. Any ideas?

private void WriteCookies()
{
HttpCookie cookie = new HttpCookie("mytest");
cookie.Domain = ".mydomain.com";
cookie.Value = "myvalue";
cookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie);
}
private void ReadCookies()
{
HttpCookie cookie;
for (int i= 0; i < Request.Cookies.Count; i ++ )
{
cookie = Request.Cookies;
if (cookie.Name == "Test")
{
Label1.Text += cookie.Name + "|" + cookie.Value+ "|" +
cookie.Domain + "|" + " ~ ";
}
}
}
 
the browser does not send the domain name with the cookie value, so its not
in the request cookies (as its unknown). only cookies in the response
(server side) have a domain.

-- bruce (sqlwork.com)



Yes I am. I can see the name and value but not the domain. Any ideas?

private void WriteCookies()
{
HttpCookie cookie = new HttpCookie("mytest");
cookie.Domain = ".mydomain.com";
cookie.Value = "myvalue";
cookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie);
}
private void ReadCookies()
{
HttpCookie cookie;
for (int i= 0; i < Request.Cookies.Count; i ++ )
{
cookie = Request.Cookies;
if (cookie.Name == "Test")
{
Label1.Text += cookie.Name + "|" + cookie.Value+ "|" +
cookie.Domain + "|" + " ~ ";
}
}
}
 

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