HttpCookie.Domain property

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.
 
J

Juan T. Llibre

Are you setting the domain ?

response.cookies("TEST").domain = "yourdomain.com"
 
U

ulabala

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 + "|" + " ~ ";
}
}
}
 
B

bruce barker \(sqlwork.com\)

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top