473,473 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

HttpCookie.Domain property

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.

Jun 16 '06 #1
3 2137
Are you setting the domain ?

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

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<ul*****@gmail.com> wrote in message news:11**********************@f6g2000cwb.googlegro ups.com...
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.

Jun 16 '06 #2
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[i];
if (cookie.Name == "Test")
{
Label1.Text += cookie.Name + "|" + cookie.Value+ "|" +
cookie.Domain + "|" + " ~ ";
}
}
}

Juan T. Llibre wrote:
Are you setting the domain ?

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

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<ul*****@gmail.com> wrote in message news:11**********************@f6g2000cwb.googlegro ups.com...
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.


Jun 16 '06 #3
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)

<ul*****@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.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[i];
if (cookie.Name == "Test")
{
Label1.Text += cookie.Name + "|" + cookie.Value+ "|" +
cookie.Domain + "|" + " ~ ";
}
}
}

Juan T. Llibre wrote:
Are you setting the domain ?

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

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<ul*****@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
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.

Jun 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: chris | last post by:
I'm struggling with using the HttpCookie object on a code behind. Used in the page works great I'm getting a: Type 'HttpCookie' is not define I've tried adding the namespace to the vb form but no...
1
by: Ivan Demkovitch | last post by:
Hi! System.Net.Cookie class offers greater flexibility for working with Cookies compare to System.Web.HttpCookie. Is there any way to work with cookies thru System.Net.Cookie instead of...
0
by: Chris | last post by:
Just a curiosity: Is it standard practice to UrlEncode and UrlDecode cookie values? I wouldn't have even stumbled across this except I noticed that when I retrieve a cookie that was set with...
1
by: Waqqas Farooq | last post by:
Can I add more than 1 values in a cookie? e.g if i create a httpcookie then the syntax would be like this: Dim myCookie as new HttpCookie("myCookieName") myCookie.Value = "myval1"...
1
by: Craig | last post by:
I'm attempting to set the domain for a cookie I'm setting. The domain is not getting set though. I need to do this because I'm setting the cookie on one server, but it will be used on another...
2
by: Tessa | last post by:
Hi, We have a .net web application, and are trying to use PrinterSettings.InstalledPrinters to list the printers installed on the webserver. (Windows 2003 server R2, IIS 6, .net framework 2.0.)...
2
by: Terry Olsen | last post by:
I don't understand the error i'm getting on this page. Is this a bug or am I doing something wrong? Exception Details: System.InvalidCastException: Unable to cast object of type...
1
by: John Grandy | last post by:
If you don't set the HttpCookie.Expires property does that mean the cookie never expires ? Thanks.
3
by: =?Utf-8?B?Q2h1Y2sgUA==?= | last post by:
What properties on a HttpCookie give invalid information when you read it from the Request object? For example if you run this code, I believe the domain, expires, and HttpOnly do not tell the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.