Sessions and sub-domains

Discussion in 'PHP' started by redhits, Nov 1, 2008.

  1. #1
    If I have 1 domain name and intend to build many sub-domains for different tools,etc, then will i have problems with session. Like if somebody will log-in to softgroups.com he will also be logged in on icredit.softgroups.com ?
     
    redhits, Nov 1, 2008 IP
  2. Sir P

    Sir P Peon

    Messages:
    76
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hi there,

    PHP has good support for this sort of things, you won't have issues. You can actually set the session path in your php script.. here's some examples...

    
    ini_set('session.cookie_domain', '.example.com')
    
    PHP:
    Note the '.' before the domain - that will set the cookie for example.com and all its subdomains.

    
    ini_set('session.cookie_domain', 'example.com')
    
    PHP:
    If you use this one, then no subdomains supported under that session.

    
    ini_set('session.cookie_domain', 'test.example.com')
    
    PHP:
    Use this one and only the test.example subdomain will be supporting your current session.

    good luck
     
    Sir P, Nov 2, 2008 IP
  3. redhits

    redhits Notable Member

    Messages:
    3,023
    Likes Received:
    277
    Best Answers:
    0
    Trophy Points:
    255
    #3
    Uhhh thanks a lot

    i can only use it for domain/sub-domains that are hosted on that server
    right?!
     
    redhits, Nov 2, 2008 IP
  4. Grit.

    Grit. Well-Known Member

    Messages:
    1,424
    Likes Received:
    22
    Best Answers:
    1
    Trophy Points:
    110
    #4
    why not just name your sessions different things? or are you intending to use pre made scripts?
     
    Grit., Nov 2, 2008 IP
  5. Sir P

    Sir P Peon

    Messages:
    76
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5

    You are correct, I'm afraid :)

    Anymore help you need just let me know..

    aham.. :eek: i'm trying to build up a rep so I can trade in this forum... feel free to click me up ../end of shameful please =]
     
    Sir P, Nov 3, 2008 IP
    redhits likes this.