By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,979 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,979 IT Pros & Developers. It's quick & easy.

Passing Cookies

P: n/a
Tom
I know how to create a cookie using the HttpCookie.
I know about setting its domain so it can be shared.
So I have created a cookie on web site A and set it to
expire in 10 minutes.

Now I am on web site B, in VS.NET C# and I want to access
the cookie created on web site A.

Is this possible?

Can anyone advise??

Here is the code:

DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(0,0,10,0);

HttpCookie MyUIDCookie = new HttpCookie("MyCookie", "some
value");
MyUIDCookie.Domain = ".mydomain.com";
Response.Cookies.Add(MyUIDCookie);

MyUIDCookie.Expires = dt.Add(ts);
Nov 15 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Tom,

If the websites A and B are within the same domain, you can retrieve cookies
from the Cookies property of the HttpRequest instance available from the
Page's Request property.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Tom" <da*****@fhlbcin.com> wrote in message
news:16****************************@phx.gbl...
I know how to create a cookie using the HttpCookie.
I know about setting its domain so it can be shared.
So I have created a cookie on web site A and set it to
expire in 10 minutes.

Now I am on web site B, in VS.NET C# and I want to access
the cookie created on web site A.

Is this possible?

Can anyone advise??

Here is the code:

DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(0,0,10,0);

HttpCookie MyUIDCookie = new HttpCookie("MyCookie", "some
value");
MyUIDCookie.Domain = ".mydomain.com";
Response.Cookies.Add(MyUIDCookie);

MyUIDCookie.Expires = dt.Add(ts);


Nov 15 '05 #2

P: n/a
Tom
Dimitria:

Yes, both web sites (A and B) are in the same domain.

And I tried these three attempts but "myCookie" always
returned null when I executed it on web site B in C#.

myCookie = Request.Cookies["MyPwdCookie"];
myCookie = HttpRequest.Current.Request.Cookies
["MyPwdCookie"];
myCookie = HttpContext.Current.Request.Cookies
["MyPwdCookie"];

HttpCookie myCookie = Page.Request.Cookies["MyPwdCookie"];

myCookie = HttpContext.Current.Request.Cookies
["MyPwdCookie"];
Can you advise further?
-----Original Message-----
Tom,

If the websites A and B are within the same domain, you can retrieve cookiesfrom the Cookies property of the HttpRequest instance available from thePage's Request property.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Tom" <da*****@fhlbcin.com> wrote in message
news:16****************************@phx.gbl...
I know how to create a cookie using the HttpCookie.
I know about setting its domain so it can be shared.
So I have created a cookie on web site A and set it to
expire in 10 minutes.

Now I am on web site B, in VS.NET C# and I want to access the cookie created on web site A.

Is this possible?

Can anyone advise??

Here is the code:

DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(0,0,10,0);

HttpCookie MyUIDCookie = new HttpCookie ("MyCookie", "some value");
MyUIDCookie.Domain = ".mydomain.com";
Response.Cookies.Add(MyUIDCookie);

MyUIDCookie.Expires = dt.Add(ts);


.

Nov 15 '05 #3

P: n/a

Hi Dmitriy,

As MSDN states, the cookies can be retrieved across the domains, please
refer to :
http://msdn.microsoft.com/library/de...us/csvr2002/ht
m/cs_sp_security_uvmp.asp

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com>
| References: <16****************************@phx.gbl>
| Subject: Re: Passing Cookies
| Date: Fri, 3 Oct 2003 17:54:10 +0300
| Lines: 42
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| X-Original-NNTP-Posting-Host: engine.validio.com.ua
| Message-ID: <3f********@nexus.validio.com.ua>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: nexus.validio.com.ua 193.41.50.2
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl!nexus.validio
.com.ua!engine.validio.com.ua
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:188768
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Tom,
|
| If the websites A and B are within the same domain, you can retrieve
cookies
| from the Cookies property of the HttpRequest instance available from the
| Page's Request property.
|
| --
| Dmitriy Lapshin [C# / .NET MVP]
| X-Unity Test Studio
| http://x-unity.miik.com.ua/teststudio.aspx
| Bring the power of unit testing to VS .NET IDE
|
| "Tom" <da*****@fhlbcin.com> wrote in message
| news:16****************************@phx.gbl...
| > I know how to create a cookie using the HttpCookie.
| > I know about setting its domain so it can be shared.
| >
| >
| > So I have created a cookie on web site A and set it to
| > expire in 10 minutes.
| >
| > Now I am on web site B, in VS.NET C# and I want to access
| > the cookie created on web site A.
| >
| > Is this possible?
| >
| > Can anyone advise??
| >
| > Here is the code:
| >
| > DateTime dt = DateTime.Now;
| > TimeSpan ts = new TimeSpan(0,0,10,0);
| >
| > HttpCookie MyUIDCookie = new HttpCookie("MyCookie", "some
| > value");
| > MyUIDCookie.Domain = ".mydomain.com";
| > Response.Cookies.Add(MyUIDCookie);
| >
| > MyUIDCookie.Expires = dt.Add(ts);
| >
| >
|
|

Nov 15 '05 #4

P: n/a
Jeffrey,

Thanks for pointing out the issue.

The article you have referred to reads:

"Before sending a request, the client browser checks to see if a cookie is
available containing a domain property that ***matches the tail of the fully
qualified domain name of the host specified in the requested URL**. If such
a cookie exists, the path property of the cookie is compared to the path
name component of the requested URL. If they match, the cookie is sent with
the request"

According to the fragment enclosed in "***"s, I beleive, the original
poster's websites A and B should have the same top-level domain name, such
as

app1.company.com

and

app2.company.com

and the client's browser, let's say IE to be specific, will never send a
cookie having its Domain attribute set to "app1.company.com" with a request
being sent to "app1.anothercompany.com"? Could you please elaborate if I am
mistaken?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Jeffrey Tan[MSFT]" <v-*****@online.microsoft.com> wrote in message
news:$F****************@cpmsftngxa06.phx.gbl...

Hi Dmitriy,

As MSDN states, the cookies can be retrieved across the domains, please
refer to :
http://msdn.microsoft.com/library/de...us/csvr2002/ht m/cs_sp_security_uvmp.asp

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Nov 15 '05 #5

P: n/a
Does anyone know if classic ASP Cookies object supports the ASP.NET
".domain" property?

Thanks

Tom


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #6

P: n/a

Hi Tom,

I found that you have asked if ASP.NET support the ".domain" property in
microsoft.public.vsnet.general queue with Subject:
"Cookie Domain Property"
And a colleague of mine has replied an answer to you, please follow up him
there, he will work with you.

Thanks for your understanding

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: Tom Daria <da*****@fhlbcin.com>
| References: <#l*************@TK2MSFTNGP11.phx.gbl>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: Re: Passing Cookies
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <#5**************@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Date: Mon, 06 Oct 2003 07:38:48 -0700
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:189244
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Does anyone know if classic ASP Cookies object supports the ASP.NET
| ".domain" property?
|
| Thanks
|
| Tom
|
|
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
|

Nov 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.