Page 1 of 1
Session problem with XP, Apache 2.0.49 and PHP 4.3.4
Posted: Thu Apr 22, 2004 3:59 am
by deljim
Hi all,
I'm running apache 2 and PHP 4.3.4 under WinXP;
My problem is that php opens a new session when i'm going from a page to another.
So the very simple code below doesn't work, the session variables cannot be retreived because the session change... The same code works on a Linux OS.
Do someone knows that problem? please help!
Thx. Jim
file : test1.php :
Code: Select all
<?php
session_start();
$_SESSION['test'] = "the_test";
?>
file : test2.php
Code: Select all
<?php
session_start();
print($_SESSION['test']);
?>
Posted: Thu Apr 22, 2004 6:05 am
by stoyan
Turn error reporting on and check if the session directory exists.
Posted: Thu Apr 22, 2004 8:20 am
by deljim
The directory exist and contains the files sess_*
The problem is that it creates a "session file" for each page visited. So when click on a link a new sess file is created. That why I cannot find variable back... Am I clear?
Posted: Thu Apr 22, 2004 8:41 am
by twigletmac
What does the sessions section of your php.ini look like?
Mac
Posted: Thu Apr 22, 2004 9:00 am
by deljim
Here is my php.ini file. I deleted the most of comments to be shorter for reading.
[Session]
; Handler used to store/retrieve data.
session.save_handler = files
session.save_path =E:/Program Files/Peaktime/xmlratserver/Apache/Server/Apache/www/sess_data
; Whether to use cookies.
session.use_cookies = 1
; This option enables administrators to make their users invulnerable to
; attacks which involve passing session ids in URLs; defaults to 0.
; session.use_only_cookies = 1
; Name of the session (used as cookie name).
session.name = PHPSESSID
; Initialize session on request startup.
session.auto_start = 0
; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0
; The path for which the cookie is valid.
session.cookie_path = E:/Program Files/Peaktime/xmlratserver/Apache Server/Apache/www/cookies
; The domain for which the cookie is valid.
session.cookie_domain =
; Handler used to serialize data. php is the standard serializer of PHP.
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = 0
session.bug_compat_warn = 0
; Check HTTP Referer to invalidate externally stored URLs containing ids.
; HTTP_REFERER has to contain this substring for the session to be
; considered as valid.
session.referer_check =
; How many bytes to read from the file.
session.entropy_length = 0
; Specified here to create the session id.
session.entropy_file =
;session.entropy_length = 16
;session.entropy_file = /dev/urandom
session.cache_limiter = nocache
; Document expires after n minutes.
session.cache_expire = 180
session.use_trans_sid = 0
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="
Posted: Thu Apr 22, 2004 9:08 am
by JAM
Tried:
Code: Select all
session.save_path = "E:\Program Files\Peaktime\xmlratserver\Apache\Server\Apache\www\sess_data"
?
Posted: Thu Apr 22, 2004 9:17 am
by redmonkey
Paths with spaces are require to be enclosed in quotes so as suggested enclose the value of seesion.save_path in quotes.
This is also the case for session.cookie_path, however you should note that the value of session.cookie_path is not a path to save files to. This value represents allowable directories for which the cookie will be accessable. So with your current config only scripts which are in the directory "E:/Program Files/Peaktime/xmlratserver/Apache Server/Apache/www/cookies" and any subsequent sub directories will be able to access the session cookie.
Posted: Thu Apr 22, 2004 9:40 am
by deljim
Thanks for advices!
My code still doesn't work, I "double-quoted" the path, I even tried to put session files in "E:\temp" but no result either. The session file are still created at each page visited...
Posted: Thu Apr 22, 2004 10:01 am
by redmonkey
Have you tried....
Code: Select all
session.save_path = "E:\temp";
session.cookie_path = /
Assuming E:\temp is a directory
I had some problems with Apache2 running as a service on win2k, I created an apache user with appropriate permissions and set that user as the logon for the Apache service. Don't think it would make any difference in your case but may be worth a shot.