Results 1 to 3 of 3

Thread: Cookies; a.x.com reading cookie from b.x.com?

  1. #1

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Cookies; a.x.com reading cookie from b.x.com?

    Lets say my website domain name is x.com, and the main site runs off www.x.com

    Then lets say I have a subdomain, lets call it xml.x.com
    Is it possible for xml.x.com to read a cookie saved by www.x.com?

    This is for authentication and to allow SSO to happen.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  2. #2

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Cookies; a.x.com reading cookie from b.x.com?

    Actually now that I think about it - when somebody logs in I can set a cookie and also set their Session() variable with the user ID. When they move onto a subdomain, I can check for the cookie and/or the session ID.

    That's my problem resolved then isn't it?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: Cookies; a.x.com reading cookie from b.x.com?

    Quote Originally Posted by plenderj
    Actually now that I think about it - when somebody logs in I can set a cookie and also set their Session() variable with the user ID. When they move onto a subdomain, I can check for the cookie and/or the session ID.

    That's my problem resolved then isn't it?

    This is from MSDN which shows how to share cookies between domain/sub-domains.

    http://msdn.microsoft.com/library/de...Cookies101.asp

    Scoping Cookies to a Domain

    By default, cookies are associated with a specific domain. For example, if your site is www.contoso.com, the cookies you write are sent to the server when users request any page from that site. (Except for cookies with a specific path value, as I explained in the section immediately preceding.) If your site has subdomains — for example, contoso.com, sales.contoso.com, and support.contoso.com — then you can associate cookies with a specific subdomain. To do so, set the cookie's Domain property, like this:

    Code:
    Response.Cookies("domain").Value = DateTime.Now.ToString
    Response.Cookies("domain").Expires = DateTime.Now.AddDays(1)
    Response.Cookies("domain").Domain = "support.contoso.com"
    When the domain is set in this way, the cookie will be available only to pages in the specified subdomain.

    You can also use the Domain property to create a cookie that can be shared among multiple subdomains. For example, set the domain as follows:

    Code:
    Response.Cookies("domain").Value = DateTime.Now.ToString
    Response.Cookies("domain").Expires = DateTime.Now.AddDays(1)
    Response.Cookies("domain").Domain = "contoso.com"
    The cookie will then be available to the primary domain as well as to sales.contoso.com and support.contoso.com.
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width