Storing PHP SESSION varibles between http://www.mysite.com and http://mysite.com

Discussion in 'Programming' started by tlshaheen, Mar 10, 2010.

  1. #1
    It seems the SESSION variables I'm storing using PHP on http://mysite.com are not being stored as session variables on http://www.mysite.com (notice the www.).
    Is this something I'm doing wrong, or is this how its meant to be? Any way I can have the variable stored for both?
     
    tlshaheen, Mar 10, 2010 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    following should help..

    ini_set("session.cookie_domain", ".mydomain.com");
     
    mastermunj, Mar 10, 2010 IP
    tlshaheen likes this.
  3. tlshaheen

    tlshaheen Peon

    Messages:
    89
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Place that in my php.ini file I'm assuming?
     
    tlshaheen, Mar 10, 2010 IP
  4. tlshaheen

    tlshaheen Peon

    Messages:
    89
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you for your response! I placed it in my login.php file and my index.php file for test purposes, at the beginning of each file, before session_start(), and I still have my problem! Any other solutions?
     
    tlshaheen, Mar 10, 2010 IP
  5. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    NeoCambell, Mar 12, 2010 IP
    tlshaheen likes this.
  6. tlshaheen

    tlshaheen Peon

    Messages:
    89
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank you, I see that it should work, I must not have been implementing it correctly. Anyway, I decided to go with a 301 redirect from http://mysite.com to the www. version. Thanks!
     
    tlshaheen, Mar 12, 2010 IP