sessions do not work

Problems with the Windows version of XAMPP, questions, comments, and anything related.

sessions do not work

Postby TheTitans » 05. February 2008 13:49

None of my PHP sessions are working. For some reason they aren't being stored properly because my php login script that uses sessions isn't working. However, I know that the script is coded properly because it works on my other server, but not xampp.

In my php.ini file, it says that sessions are stored in the C:\xampp\tmp folder. I do see a few session files there. I'm not sure if they are from my script or not though. Need some help.
TheTitans
 
Posts: 5
Joined: 04. February 2008 04:53

Postby Scory » 05. February 2008 15:14

Sessions requires cookies - are cookies enabled in your browser for the domain you are testing?
Scory
 

Postby TheTitans » 06. February 2008 00:39

I am testing under http://localhost/
My actual browser, Firefox, does allow cookies.
Do I need to edit a setting in my php.ini file?
TheTitans
 
Posts: 5
Joined: 04. February 2008 04:53

Postby sari42 » 06. February 2008 11:37

>I do see a few session files there
then apparently sessions can be created by php.

>I know that the script is coded properly because it works on my other server,
that's no proof.

compare the outputs of
<?php phpinfo(); //saved as info.php ?>
on both servers, maybe the "other" server has register_globals "On" or allow_short_open_tags "On" or somesuch.

_________
p.s.
simple test script:
Code: Select all
<?php
//store as, e.g., session_wr.php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
@session_start();
echo 'php-session write/read test, please reload the page (F5) ...<p>
$_SESSION["ts"] was ',
empty($_SESSION['ts'])
? '<b>not yet</b> set.'
: 'updated <b>' . (time() - $_SESSION['ts']) . '</b> seconds ago';
$_SESSION['ts'] = time();
?>
Last edited by sari42 on 06. February 2008 13:05, edited 2 times in total.
sari42
 
Posts: 800
Joined: 27. November 2005 18:28

Postby TheTitans » 06. February 2008 12:31

register_globals is "on" on the other server as well as short_open_tag. In xampp, register_globals is turned off, but short_open_tag is turned on.
TheTitans
 
Posts: 5
Joined: 04. February 2008 04:53

Postby sari42 » 06. February 2008 12:49

quick and dirty workaround:
set register_globals "On" in php.ini or
php_value register_globals 1 in .htaccess

or better amend all your scripts (more secure and mandatory for php6, see http://php.net/manual/en/security.globals.php ),
e.g., change $login_name to $_POST['login_name']
sari42
 
Posts: 800
Joined: 27. November 2005 18:28


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 138 guests