pass cookie in two domains work in IE, but not working in firefox?

Discussion in 'ASP General' started by c676228, Apr 9, 2008.

  1. c676228

    c676228 Guest

    Hi All

    I have the following code which we want the query string value to be passed
    from domain A to domain B.
    www.domain1.com/program1.asp?12345
    then we later on if customer navigates from domain1 to domain2, it should
    bececome like this:
    www.domain2.com/whatever.asp?12345
    Suddenly we found out it only works in IE 7.0 and not working in firefox.
    the code is as follow:


    Dim HttpStr, LiveFlag
    LiveFlag=True
    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") ="56789"
    Else
    Response.Cookies("id")=id
    End If
    End If

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

    id = Request.Cookies("id")

    I have a function which is used to write a link dynamically for domain2, so
    the id could be attached to the link:
    Function WriteLinkPgm(byVal Domain2, byVal Pgm, byVal DisplayText)


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

    End Function

    The id is attached in IE 7.0 and but firefox doesn't follow that.
    it always has the format like this in firefox:
    www.domain2.com/whatever.asp?56789

    It seems that it never get 12345 query string

    What's going on here? Can you guys shed light on me?

    thank you so much.
    --
    Betty
     
    c676228, Apr 9, 2008
    #1
    1. Advertising

  2. Hi Betty,

    From your description, you're using cookie to share querystring values
    between multiple web site(different top level domain name), correct?

    Based on my understanding, for cookie itself, it is not allowed to share
    between different web applications with different domain name(top level
    domain). So far only cookies in websites that has identical parent domain
    can be shared directly with each other. And for different websites with
    different domain name, the current approach for sharing cookie is also rely
    on querystring, also you need to explicitly provide a "cookie provider
    page" in the certain site that contains the cookie and let another web site
    use Response.Redirect to visit that page and that page will append cookie
    in the querystring and redirect back to the original url.

    For example, SiteA need cookie on SiteB:

    **SiteB need a cookie provideer page(suppose named cookieprovider.asp).
    this page will get parameters from querystring to determine which cookie
    value does the requester need and retrieve those values. Then it use
    response.redirecct to redirct back to siteA(append cookie in querystring)

    ** SiteA send response.Redirect to SiteB's cookieprovider.asp page(with the
    cookie names or the original url if necessary in querystring)

    ** SiteB's cookieprovider page get parameters from url querystring and read
    the certain cookie values. Append it to url querystring and redirect back
    to SiteA's page.

    #Sharing Cookies Across Domains
    http://www.15seconds.com/issue/971108.htm

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.


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



    --------------------

    >From: =?Utf-8?B?YzY3NjIyOA==?= <>
    >Subject: pass cookie in two domains work in IE, but not working in firefox?
    >Date: Wed, 9 Apr 2008 09:36:03 -0700


    >
    >Hi All
    >
    >I have the following code which we want the query string value to be

    passed
    >from domain A to domain B.
    >www.domain1.com/program1.asp?12345
    >then we later on if customer navigates from domain1 to domain2, it should
    >bececome like this:
    >www.domain2.com/whatever.asp?12345
    >Suddenly we found out it only works in IE 7.0 and not working in firefox.
    >the code is as follow:
    >
    >
    >Dim HttpStr, LiveFlag
    >LiveFlag=True
    >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") ="56789"
    > Else
    > Response.Cookies("id")=id
    > End If
    >End If
    >
    >Response.Cookies("id").Domain = ".domain1.com"
    >Response.Cookies("id").Expires = "December 31, 2020"
    >Response.cookies("id").path="/"
    >
    >id = Request.Cookies("id")
    >
    >I have a function which is used to write a link dynamically for domain2,

    so
    >the id could be attached to the link:
    >Function WriteLinkPgm(byVal Domain2, byVal Pgm, byVal DisplayText)
    >
    >
    > WriteLinkPgm="<A HREF=" & HttpStr & Domain2 & Pgm & "?" & id & ">" &
    >DisplayText & "</A>"
    >
    >End Function
    >
    >The id is attached in IE 7.0 and but firefox doesn't follow that.
    >it always has the format like this in firefox:
    >www.domain2.com/whatever.asp?56789
    >
    >It seems that it never get 12345 query string
    >
    >What's going on here? Can you guys shed light on me?
    >
    >thank you so much.
    >--
    >Betty
    >
     
    Steven Cheng [MSFT], Apr 10, 2008
    #2
    1. Advertising

  3. c676228

    Evertjan. Guest

    Steven Cheng [MSFT] wrote on 10 apr 2008 in
    microsoft.public.inetserver.asp.general:

    > Hi Betty,
    >
    > From your description, you're using cookie to share querystring values
    > between multiple web site(different top level domain name), correct?
    >
    > Based on my understanding, for cookie itself, it is not allowed to
    > share between different web applications with different domain
    > name(top level domain). So far only cookies in websites that has
    > identical parent domain can be shared directly with each other. And
    > for different websites with different domain name, the current
    > approach for sharing cookie is also rely on querystring, also you need
    > to explicitly provide a "cookie provider page" in the certain site
    > that contains the cookie and let another web site use
    > Response.Redirect to visit that page and that page will append cookie
    > in the querystring and redirect back to the original url.
    >
    > For example, SiteA need cookie on SiteB:
    >
    > **SiteB need a cookie provideer page(suppose named
    > cookieprovider.asp). this page will get parameters from querystring to
    > determine which cookie value does the requester need and retrieve
    > those values. Then it use response.redirecct to redirct back to
    > siteA(append cookie in querystring)


    Why not use a [hidden] iframe in stead of a response.redirect?

    <iframe
    href='http://other.com/cprov.asp?c=<%=Request.Cookies("A")%>&cn=A'
    style='display:none;'></iframe>

    >
    > ** SiteA send response.Redirect to SiteB's cookieprovider.asp
    > page(with the cookie names or the original url if necessary in
    > querystring)
    >
    > ** SiteB's cookieprovider page get parameters from url querystring and
    > read the certain cookie values. Append it to url querystring and
    > redirect back to SiteA's page.




    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Apr 10, 2008
    #3
  4. c676228

    c676228 Guest

    Hi Steven,

    I probably didn't make things clear.
    The following function call is sitting on domain1 and write a dynamic link
    on domain1 for linking to domain2 will use the following function call. I
    didn't share the cookies directly.

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


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

    End Function


    But I fixed yesterday I just replaced "id" with a very strange name. It
    works perfectly fine in both IE and firefox. But still not figured out why is
    that.

    I haven't get a chance to read your and evertjan's response yet. I will get
    back to you as soon as I can. Too busy with some other stuff.
    --
    Betty


    "c676228" wrote:

    > Hi All
    >
    > I have the following code which we want the query string value to be passed
    > from domain A to domain B.
    > www.domain1.com/program1.asp?12345
    > then we later on if customer navigates from domain1 to domain2, it should
    > bececome like this:
    > www.domain2.com/whatever.asp?12345
    > Suddenly we found out it only works in IE 7.0 and not working in firefox.
    > the code is as follow:
    >
    >
    > Dim HttpStr, LiveFlag
    > LiveFlag=True
    > 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") ="56789"
    > Else
    > Response.Cookies("id")=id
    > End If
    > End If
    >
    > Response.Cookies("id").Domain = ".domain1.com"
    > Response.Cookies("id").Expires = "December 31, 2020"
    > Response.cookies("id").path="/"
    >
    > id = Request.Cookies("id")
    >
    > I have a function which is used to write a link dynamically for domain2, so
    > the id could be attached to the link:
    > Function WriteLinkPgm(byVal Domain2, byVal Pgm, byVal DisplayText)
    >
    >
    > WriteLinkPgm="<A HREF=" & HttpStr & Domain2 & Pgm & "?" & id & ">" &
    > DisplayText & "</A>"
    >
    > End Function
    >
    > The id is attached in IE 7.0 and but firefox doesn't follow that.
    > it always has the format like this in firefox:
    > www.domain2.com/whatever.asp?56789
    >
    > It seems that it never get 12345 query string
    >
    > What's going on here? Can you guys shed light on me?
    >
    > thank you so much.
    > --
    > Betty
     
    c676228, Apr 10, 2008
    #4
  5. Thanks for your reply Betty,

    No problem. If you need any further help, please feel free to post here.

    Good luck!

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

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

    --------------------
    >From: =?Utf-8?B?YzY3NjIyOA==?= <>
    >References: <>
    >Subject: RE: pass cookie in two domains work in IE, but not working in

    firefox?
    >Date: Thu, 10 Apr 2008 09:41:03 -0700


    >
    >Hi Steven,
    >
    >I probably didn't make things clear.
    >The following function call is sitting on domain1 and write a dynamic link
    >on domain1 for linking to domain2 will use the following function call. I
    >didn't share the cookies directly.
    >
    >Function WriteLinkPgm(byVal Domain2, byVal Pgm, byVal DisplayText)
    >
    >
    >WriteLinkPgm="<A HREF=" & HttpStr & Domain2 & Pgm & "?" & id & ">" &
    >DisplayText & "</A>"
    >
    >End Function
    >
    >
    >But I fixed yesterday I just replaced "id" with a very strange name. It
    >works perfectly fine in both IE and firefox. But still not figured out why

    is
    >that.
    >
    >I haven't get a chance to read your and evertjan's response yet. I will

    get
    >back to you as soon as I can. Too busy with some other stuff.
    >--
    >Betty
    >
    >
    >"c676228" wrote:
    >
    >> Hi All
    >>
    >> I have the following code which we want the query string value to be

    passed
    >> from domain A to domain B.
    >> www.domain1.com/program1.asp?12345
    >> then we later on if customer navigates from domain1 to domain2, it

    should
    >> bececome like this:
    >> www.domain2.com/whatever.asp?12345
    >> Suddenly we found out it only works in IE 7.0 and not working in firefox.
    >> the code is as follow:
    >>
    >>
    >> Dim HttpStr, LiveFlag
    >> LiveFlag=True
    >> 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") ="56789"
    >> Else
    >> Response.Cookies("id")=id
    >> End If
    >> End If
    >>
    >> Response.Cookies("id").Domain = ".domain1.com"
    >> Response.Cookies("id").Expires = "December 31, 2020"
    >> Response.cookies("id").path="/"
    >>
    >> id = Request.Cookies("id")
    >>
    >> I have a function which is used to write a link dynamically for domain2,

    so
    >> the id could be attached to the link:
    >> Function WriteLinkPgm(byVal Domain2, byVal Pgm, byVal DisplayText)
    >>
    >>
    >> WriteLinkPgm="<A HREF=" & HttpStr & Domain2 & Pgm & "?" & id & ">" &
    >> DisplayText & "</A>"
    >>
    >> End Function
    >>
    >> The id is attached in IE 7.0 and but firefox doesn't follow that.
    >> it always has the format like this in firefox:
    >> www.domain2.com/whatever.asp?56789
    >>
    >> It seems that it never get 12345 query string
    >>
    >> What's going on here? Can you guys shed light on me?
    >>
    >> thank you so much.
    >> --
    >> Betty

    >
     
    Steven Cheng [MSFT], Apr 11, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martin
    Replies:
    3
    Views:
    1,239
    bruce barker
    Oct 7, 2004
  2. =?Utf-8?B?RG91Zw==?=

    Session Cookie not accessible across Sub-Domains

    =?Utf-8?B?RG91Zw==?=, Aug 22, 2005, in forum: ASP .Net
    Replies:
    14
    Views:
    29,248
    anilchanna
    Nov 6, 2009
  3. Harlin Seritt
    Replies:
    5
    Views:
    652
    Kent Johnson
    Feb 22, 2006
  4. Owen
    Replies:
    5
    Views:
    418
    Yan-Hong Huang[MSFT]
    Feb 23, 2004
  5. WeAreGoing!
    Replies:
    1
    Views:
    170
    Lasse Reichstein Nielsen
    Dec 1, 2003
Loading...

Share This Page