473,322 Members | 1,566 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Passing Cookies

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
6 2542
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
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

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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page...
1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
6
by: Rob Meade | last post by:
Hi all, At work we have 2 servers in a cluster for our web apps. One problem we have experienced (along with many others!) - is that if a user is logged into one of the applications on server...
6
by: Mark | last post by:
hi, how can i pass state for each user through pages without using session,cookies,hidden form fields,querystring or database, which knowledge base article 175167 refers? i don't want to build a...
10
by: vbMark | last post by:
Hello, I am doing this: window.location="page2.php?subj="+subj+"&body="+body; to send information to another page. However, I don't want that second page to show up or display in any way....
22
by: K. A. | last post by:
I have two servers at work, 'A' for testing and development, and server 'B' for production. On server A, I wrote a PHP test code to login users then direct them to a personalized page. This is...
4
idsanjeev
by: idsanjeev | last post by:
SIR I AM PASSING VALUE FROM ONE FORM TO ANOTHER FORM THROUGH COOKIES BUT IS CAN ONLY TRANSFER LAST VALUE HOW CAN PASS VALUE AFTER CLICKIN ON LINK I AM USING THE CODE IS FOR LINK <td><a...
3
by: =?Utf-8?B?QW5keQ==?= | last post by:
Hi, I'm having issues with what I'm *sure* is a simple problem. Basically having a problem passing a cookie between two sites. On Site A you sign in, and create a cookie with the users ID in it...
10
BezerkRogue
by: BezerkRogue | last post by:
I am trying to use cookies to manage session states in an ASP.NET application. The states need to persist only while the browser session is open. My web.config setting is: <system.web>...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.