session problem

Discussion in 'PHP' started by dizyn, Feb 6, 2008.

  1. #1
    I 3 sub domains, I log on to one domain and want to retain that login for all three sub domains.

    Example:

    If I logged on to beta.cmela.com session is working fine there but I want to retain that session for classifieds.cmela.com and community.cmela.com as well.

    what should i need to do for it?

    thank you
    dizyn
     
    dizyn, Feb 6, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    ini_set('session.cookie_domain', '.cmela.com');
    
    PHP:
    Put this before your session_start() call.
     
    nico_swd, Feb 6, 2008 IP
  3. mvl

    mvl Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    1. The session cookie should be set for the domein .cmela.com, not for any of the subdomains.
    2. The session data should be stored in the same place for all three subdomains. If you store them on your file system you should use the same directory for all, if you store them in a database, use the same database for every subdomain.
     
    mvl, Feb 6, 2008 IP
  4. dizyn

    dizyn Active Member

    Messages:
    251
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    i used:
    ini_set('session.cookie_domain', '.cmela.com');
    but no luck,

    Please tell me how can i store session data on one place?

    thank you
     
    dizyn, Feb 6, 2008 IP
  5. mvl

    mvl Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Depends on which handler you use. Assuming you store sessions on the file system the session use session_save_path($path); with $path being the same for all subdomains before session_start() is called. Calling session_save_path() without a parameters returns the currently used path.

    It really helps to try and understand the session mechanism in PHP. It can be a tough read but it is nearly impossible to tweak session handling if you don't understand what you are doing:

    Session docs on php.net
     
    mvl, Feb 6, 2008 IP
  6. dizyn

    dizyn Active Member

    Messages:
    251
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #6
    Ok, thank you, I am going to read it and then hopefully will get result.
     
    dizyn, Feb 6, 2008 IP
  7. dizyn

    dizyn Active Member

    Messages:
    251
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #7
    In my settings:

    and my session.save_handler value is: "files"
    session.save_path: "no path" -> can i set a value for it? do i need to set a value for it?

    session.cookie_path value is: /
    will this save data in current directory in which i am?
     
    dizyn, Feb 6, 2008 IP