Forum Moderators: coopster

Message Too Old, No Replies

Session not retained on pages in subfolder

         

dbzfyam

1:14 pm on Sep 9, 2008 (gmt 0)

10+ Year Member



I currently have this on my main page:

if(!is_dir("sessions")) {mkdir("sessions", 0777);}
session_set_cookie_params(315360000, "/");
session_save_path("sessions");
session_start();

And this on a page in a subfolder:


if(!is_dir("../sessions")) {mkdir("../sessions", 0777);}
session_set_cookie_params(315360000, "/");
session_save_path("../sessions");
session_start();

For some reason the session vanishes if I go to a page in the subfolder. When I log in on my main page, I should be able to go to scripts in the subfolder. I checked my sessions folder and the main page seems to work correctly (creates a session file and adds data to it). However, when I go to a page in the subfolder, PHP created a new session file in that folder which is empty. Also, when I move that file to the document root (where my main file also is located) the script works (after changing the paths of course).

Does anyonw know how to solve this? There are about 20 scripts inside that subfolder so it becomes quite a mess if I would move them all to the document root.

Thanks in advance
Stefan

omoutop

1:47 pm on Sep 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I don't see anything wrong in your code

wild guess here and i may be totally off topic, misdirecting you but try using session_save_path($_SERVER['DOCUMENT_ROOT']."/sessions");
and see if this works

dbzfyam

2:04 pm on Sep 9, 2008 (gmt 0)

10+ Year Member



Thanks for the fast reply. I just tried that, but sadly it doesn't work.