How do I set session storage location from my php.ini file?

Discussion in 'PHP' started by Imozeb, Jun 23, 2010.

  1. #1
    How do I set my session storage location from my php.ini file?

    Also would I need to set anything else in my php.ini file since I am changing the location of my sessions?

    Thanks.
     
    Imozeb, Jun 23, 2010 IP
  2. getlandersgetpaid

    getlandersgetpaid Guest

    Messages:
    41
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    getlandersgetpaid, Jun 24, 2010 IP
  3. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    But since this isn't in my php.ini file doesn't that mean that I would have to call it every time I use session_start()? If so is there anyway I can set it in my php.ini file so I don't have to call it over and over again?
     
    Imozeb, Jun 24, 2010 IP
  4. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is there any code I could put in my php.ini file which would change the session store path?
     
    Imozeb, Jun 26, 2010 IP
  5. happpy

    happpy Well-Known Member

    Messages:
    926
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    120
    #5
    simply change the value in the ini file.

    get the value in your script: $sessiondir=ini_get('session.save_path');

    given that your server supports this:
    set the value in your script: $sessiondir=ini_set('session.save_path',"some/path/here");
     
    happpy, Jun 26, 2010 IP
  6. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks. One more question though. I want to set the session save path so I can count the number of session files but I am worried that it is not as secure as /tmp (the default). If I specify a new path say /sessions/users/ will hackers be able to hack my session data easily since it is not outside the root?

    Thanks.
     
    Imozeb, Jun 29, 2010 IP