SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to retain session variable between domain and sub domain

    Can any one suggest me how to retain session variable between domains and sub domains

    like how can i access a variable set in

    http://g2.com


    in:
    http://abc.g2.com

  2. #2
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to set the session cookie domain to ".g2.com" (yes, that's a DOT in front). That way the cookie will work on any hostname ending with that domain.

  3. #3
    SitePoint Addict webaddictz's Avatar
    Join Date
    Feb 2006
    Location
    Netherlands
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Czaries View Post
    You need to set the session cookie domain to ".g2.com" (yes, that's a DOT in front). That way the cookie will work on any hostname ending with that domain.
    Please be advised: if your domainname is shorter than four characters, using .g2.com will not work in Opera. The reason for this is that Opera figured that we're talking about .com.au or .co.uk, and didn't take a domainname of two or three characters into account. Just so you don't hit yourself in the head: me and my colleage have been debugging that weirdness for hours!

    EDIT: Seems I have to clarify this a little: it will only accept the cookie if there's an A record for g2.com which is the same IP address as the subdomain.
    Last edited by webaddictz; Mar 16, 2009 at 01:05.
    Yes, I blog, too.


Bookmarks

Posting Permissions

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