pass cookie from one domain to another on the same server

C

c676228

Hi all,
Is there an easier way to handle that? I used Javascript to handle this when
our two domains are hosted on two different servers(on different networks)
and our search engine marketing people don't like the javascript links since
they think the links are not favorable to a search robot.

Now our company is thinking about hosting these two domians on the same
server,
So I am wodering if there is any easy way to do that. Would you provide me
some clues?
Thank you so much.
 
E

Evertjan.

=?Utf-8?B?YzY3NjIyOA==?= wrote on 21 nov 2007 in
microsoft.public.inetserver.asp.general:
Is there an easier way to handle that?

Please do not use the subjectline as part of your Q.
I used Javascript to handle
this when our two domains are hosted on two different servers(on
different networks)

Cookies exist on the client per domain, and cannot be passed to another
domain.

The cookie content string can be palced on two domains seperately.
and our search engine marketing people don't like
the javascript links since they think the links are not favorable to a
search robot.

Sorry? Does this have anything to do with your Q?
Now our company is thinking about hosting these two domians on the
same server,
So I am wodering if there is any easy way to do that. Would you
provide me some clues?

What you can do with two domains on two servers, you can do with two
domains on one server. Cookies do not live on a server.

Any reason why this sould not be the case?
 
S

Steven Cheng[MSFT]

Hi Betty,

As for the "copy cookie from one domain to another", I'd like to confirm
the exact things you want to achieve:

** cookie is stored on client machine and whenever browser visit a site, it
will send the cookies (belong to that site based on the server domain name)
to server.

** when you change cookies, that means you change the cookies at
server-side and it is until the response reach client will the cookies data
actually be updated in client store

** For cookies, your server-side code(ASP or ASP.NET) can only add/remove
cookie within its own domain(or the same main domain and different sub
domain).

Therefore, normally, manipulate cookies under same top domain (and
different sub domains) are directly supported. However, if you want to
manipulate cookies for different top domain in single application, you will
need particular machnism setup in your context(for all those
applications/sites that want to share cookies). Here is an article
discussing something about this:

#Sharing Cookies Across Domains
http://support.softartisans.com/kbview_666.aspx

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.





--------------------
 
B

Brynn

Hi all,
Is there an easier way to handle that? I used Javascript to handle this when
our two domains are hosted on two different servers(on different networks)
and our search engine marketing people don't like the javascript links since
they think the links are not favorable to a search robot.

Now our company is thinking about hosting these two domians on the same
server,
So I am wodering if there is any easy way to do that. Would you provide me
some clues?
Thank you so much.

I would also be interested in knowing what you are storing in those
cookies.

I have changed almost everything over to server side data storage,
including shopping carts, etc... all on my servers.

The only thing the cookie does for me is keeps them unique for me. If
I wanted them to be on 2 domains ... during a login process I would
simply have a data pass to a cookie on the other domain. I like to use
invisible iframes in my pages for passes like that.

I had one project that I wanted to keep a session alive between 2
sites even ... I think I used a 1px by 1px iframe in the footer of
both websites that was a blank design asp webpage.

Anyway, let us know more about what you are doing between them,

Brynn Curry
 
C

c676228

Hi all,
Thanks for your reply. Here is my case.
Our company initially(about more than 5 years ago) has a web site(domain A)
which is hosted by a company on a lynix system. Later on our company decided
to have some dynamic pages(sales processes) which were written in asp on our
site too. So the company decided to host those pages on a different
domain(domain B) with another hosting company. So when one of our customers
gets on to our page 1 on domain A from a specific agents site, (we always
have a producer code, stored as a cookie, assigned to our specific agent),
and then if this customer's navigation on our domain A lead to a sale on our
domain B, say page 2, then this cookie values need to be carried onto domain
B, so this value could be written into our database and the sales credit will
go to our specific agents.

When we pass our cookie value from domain A to domain B, I used the
javascript. that's why I am asking th question. I am trying to think about
another way which will be better for search engine.
Thank you.
 
S

Steven Cheng[MSFT]

Hi Betty,

Yes, you may need to look for some other approaches. For share cookie, I
think the last link in my previous reply (below) should be a doable
appraoch:

http://support.softartisans.com/kbview_666.aspx

Hi BeSharp,

As for the D LINQ selection scenario you mentioned, I think it sounds like
what you want to do is a SQL "LIKE" comparison. For {"...",
"..."}.contains, "contains" actually means that the input parameter exactly
match any of the i tem in collection, that is not substring mapping. For
substring mapping, you should use SQL "Like" style selection. Here is a web
thread discussing on using "LIKE" query in LINQ:

#using LIKE in DLinq
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=308989&SiteID=1

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.





--------------------
 
C

c676228

Hi Steven,
You are right. The link you provided is dorable for my case. In order to
replace all javascript coded links from domain A, I need to replace all the
html pages on domain A to .asp page, so I can pass cookie value from query
string from domain A to domain B. This will be beneficail to site traffic
since a crawler will index those pages.

Thank you so much for your great help
--
Betty


Steven Cheng said:
Hi Betty,

Yes, you may need to look for some other approaches. For share cookie, I
think the last link in my previous reply (below) should be a doable
appraoch:

http://support.softartisans.com/kbview_666.aspx

Hi BeSharp,

As for the D LINQ selection scenario you mentioned, I think it sounds like
what you want to do is a SQL "LIKE" comparison. For {"...",
"..."}.contains, "contains" actually means that the input parameter exactly
match any of the i tem in collection, that is not substring mapping. For
substring mapping, you should use SQL "Like" style selection. Here is a web
thread discussing on using "LIKE" query in LINQ:

#using LIKE in DLinq
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=308989&SiteID=1

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.





--------------------
 
S

Steven Cheng[MSFT]

You're welcome :)

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
X-WBNR-Posting-Host: 12.104.97.211
From: =?Utf-8?B?YzY3NjIyOA==?= <[email protected]>
Subject: Re: pass cookie from one domain to another on the same server
Date: Thu, 29 Nov 2007 10:15:03 -0800
 
C

c676228

Hi Steven,

I am bit confused about cookie again.
Based on the informaiton you provided. I have the following asp code to pass
a cookie id value from domainA to domainB. But it seems that cookie
behaviors in firefox and IE are different and also the cookie value written
by IE cannot be recognized by firefox and vise vursa.

What this code basically does is check the querystring to see if the number
is there, if yes, set the value to the cookie called id, if not, we check the
cookie id on client's machine for this domainA , if it is there,use this
value as cookie id value, if not, assign a default number 12345 to this
cookie id.

function WriteLinkPgm is for creating a dynamic link to domainB with this
cookie id value attached to a specific link.

When I tested in IE, everything seems to work as what I want. but when I use
firefox to do the testing and when I close the first firefox browser, the
initial cookie value cannot be recognized by the second firefox browser, say
the initial is 22222, the second browser id value will be "12345"
instead(which is a default value.) if this time the web address doesn't have
a specific number attached, but I want 22222. why firefox forgets, but if I
leave the first firefox open, it works. but I did set the expires property,
besides, when you open both IE and firefox two browsers, it seems that the
cookie value set up by one of the browsers cannot be recognized by the other,
I set the domain property and path, how come?

Sincerely
Betty

<%
Dim HttpStr, LiveFlag
LiveFlag=False
If LiveFlag Then
HttpStr="https://"
Else
HttpStr="http://"
End If


pcnumber = Request.ServerVariables("QUERY_STRING")
If NOT isNULL(pcnumber) and Len(pcnumber)>=5 and Len(pcnumber)<=7 Then
Response.Cookies("id") = pcnumber
Else
id = Request.Cookies("id")
If ((IsNull(Trim(id))) OR (Trim(Len(id)) = 0)) Then
Response.Cookies("id") ="12345" 'a defualt cookie value
Else
Response.Cookies("id")=id
End If
End If

Response.Cookies("id").Domain = ".domainA.com"
Response.Cookies("id").Expires = "December 31, 2020"
Response.cookies("id").path="/"

id = Request.Cookies("id")

Function WriteLinkPgm(byVal DomainB, byVal Pgm, byVal DisplayText)

WriteLinkPgm="<A HREF=" & HttpStr & DomainB & Pgm & "?" & id & ">" &
DisplayText & "</A>"

End Function
%>
 
C

c676228

Hi all,

At least I figured out part of it. Firefox gives user more control about the
cookies. So my firefox somehow set up the cookie like "keep it until I close
browser" not " until they expire".
That's why the firefox cannot remember the cookies set up in the former
session. If it sets to until they expire, everything is just like IE.

But I still don't get the part why the cookies set up by IE cannot be
recognized by firefox.
 
A

Adrienne Boswell

Gazing into my crystal ball I observed =?Utf-8?B?YzY3NjIyOA==?=
Hi all,

At least I figured out part of it. Firefox gives user more control
about the cookies. So my firefox somehow set up the cookie like "keep
it until I close browser" not " until they expire".
That's why the firefox cannot remember the cookies set up in the
former session. If it sets to until they expire, everything is just
like IE.

But I still don't get the part why the cookies set up by IE cannot be
recognized by firefox.

Because it is two different browsers, with two different cookie folders.
I have Opera, Safari, IE (several versions), and Firefox. I can open
them all, and each will have a different cookie.
 
S

Steven Cheng[MSFT]

Hi Betty,

As for the cookie, I agree with Adrienne that different browser may have
different implementatin to persist cookies at client-side. Therefore, if
you visit the same site via different browsers, cookies are not supposed to
share between them. BTW, I've also updated you in your another new thread.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
Subject: Re: pass cookie from one domain to another on the same server
Date: Fri, 25 Jan 2008 15:31:01 -0800
 
C

c676228

Hi Steven,
I searched for a while, it seems someone implement in php to handle cookies
among different browser, wondering if you have any that kind of leads in asp.

Sincerely
 
S

Steven Cheng[MSFT]

Hi Betty,

As for sharing cookie, so far what I've got is how to share cookies between
different domain or between different site such as ASP.NET/ASP or JSP. For
different client browsers, I'm afraid it would be not quite doable since
the browser's cookie setting is totally managed at client-side. Also, for
server-side web technology, how the client process cookie is completely
transparent, that's why I think it would be quite doable here. If you want
to make sure users using both browsers have a certain state set in cookie,
I think you may do some checking at the begining of each page. For example,
in your page, always check whether a cookie item exists, if not, generate
it.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.






--------------------
From: =?Utf-8?B?YzY3NjIyOA==?= <[email protected]>
Subject: Re: pass cookie from one domain to another on the same server
Date: Tue, 29 Jan 2008 08:52:33 -0800
 

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

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top