473,720 Members | 2,871 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("MyC ookie", "some
value");
MyUIDCookie.Dom ain = ".mydomain.com" ;
Response.Cookie s.Add(MyUIDCook ie);

MyUIDCookie.Exp ires = dt.Add(ts);
Nov 15 '05 #1
6 2561
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*****@fhlbci n.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("MyC ookie", "some
value");
MyUIDCookie.Dom ain = ".mydomain.com" ;
Response.Cookie s.Add(MyUIDCook ie);

MyUIDCookie.Exp ires = 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["MyPwdCooki e"];
myCookie = HttpRequest.Cur rent.Request.Co okies
["MyPwdCooki e"];
myCookie = HttpContext.Cur rent.Request.Co okies
["MyPwdCooki e"];

HttpCookie myCookie = Page.Request.Co okies["MyPwdCooki e"];

myCookie = HttpContext.Cur rent.Request.Co okies
["MyPwdCooki e"];
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*****@fhlbci n.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.Dom ain = ".mydomain.com" ;
Response.Cookie s.Add(MyUIDCook ie);

MyUIDCookie.Exp ires = 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.c om>
| 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********@nex us.validio.com. ua>
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| NNTP-Posting-Host: nexus.validio.c om.ua 193.41.50.2
| Path:
cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!tk2 msftngp13.phx.g bl!nexus.validi o
.com.ua!engine. validio.com.ua
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1887 68
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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*****@fhlbci n.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("MyC ookie", "some
| > value");
| > MyUIDCookie.Dom ain = ".mydomain.com" ;
| > Response.Cookie s.Add(MyUIDCook ie);
| >
| > MyUIDCookie.Exp ires = 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.co m

and

app2.company.co m

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.c om" with a request
being sent to "app1.anotherco mpany.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.mi crosoft.com> wrote in message
news:$F******** ********@cpmsft ngxa06.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.publi c.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*****@fhlbci n.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.publi c.dotnet.langua ges.csharp
| Date: Mon, 06 Oct 2003 07:38:48 -0700
| NNTP-Posting-Host: actionjackson13 3.dsl.frii.net 216.17.147.133
| Lines: 1
| Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP11.phx.g bl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1892 44
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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
5942
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 contains: <?php $_SESSION = ""; $_SESSION = "";
1
7784
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: ---------------------------------------------------------------------------- <?php ini_set("session.use_cookies", "off"); ini_set("session.use_trans_sid", "on"); session_start(); $_SESSION = ""; $_SESSION = ""; echo "<form method='POST' action='login.php'>
6
2252
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 a for example and it goes offline or fails their session is lost also - even though the application becomes available on server b. I have heard that it is possible to either exchange the sessions between
6
1482
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 form with hidden fields and get it posted on the client. it seems possible using server variables, response.addheader method, but how can i use it? thanks
10
2464
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. There is only behind-the-scenes work going on in that page.
22
14895
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 done in 3 steps: Step 1. Normal http login page. Step 2. A page called login.php that takes the posted username, stores it as $_SESSION, and registers it session_register("username"); user is taken to the personalized page according to his username...
4
2823
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 href=voicereply.asp?opt1=<%=R("top_id")%>>Reply</a></td> FOR STORING IN COOKIES response.cookies("vtopid")=R("top_id") TO PASS ON NEXT PAGE AND WANT TO INSERT TOPID IN TO TABLE FOR DISLAY
3
1851
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 When the user wants to purchase anything (and enter CC details) we want to pass the user to the secure site, which is on the same server. Alas the cookie is not being picked up on the secure site. a) Both sites are on the same box
10
2033
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> <sessionState cookieless="UseCookies"/> I have tried using the following code to create the cookies: Response.Cookies("FLI").Value = cmpFLI
0
8833
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8727
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9210
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9126
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5972
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4482
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3186
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 we have to send another system
2
2567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2125
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.