Having problems with sessions
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Code: Select all
<?php session_start(); ?>
<html>
<head><title>session test</head>
<body>
<?php echo 'time: ', date('H:i:s'), ' | id:', session_id(); ?>
<br />
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">reload</a>
</body>
</html>-
Stephen Bungert
- Forum Commoner
- Posts: 25
- Joined: Sat Feb 25, 2006 3:22 am
Yes, JavaScript is on. I use it all the time.
volka, Your script shows an empty page. Not even the title is in the title path of the browser, just the actuall physical path on the server: 'http://localhost/php_test_2.php'
volka, Your script shows an empty page. Not even the title is in the title path of the browser, just the actuall physical path on the server: 'http://localhost/php_test_2.php'
-
Stephen Bungert
- Forum Commoner
- Posts: 25
- Joined: Sat Feb 25, 2006 3:22 am
Volka, when I was doing test on my own php login system (before starting my thread here) I noticed that every time I refereshed the page I got a new Session ID, if this helps diagnose my problem. Can't get your code to work.
I never thought anything about the changing ID, it was the first time that I'd tried using sessions... I thought it must be supposed to change like that so I never mentioned it before.
I never thought anything about the changing ID, it was the first time that I'd tried using sessions... I thought it must be supposed to change like that so I never mentioned it before.
Last edited by Stephen Bungert on Fri Oct 06, 2006 3:11 pm, edited 1 time in total.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Try this one:
Code: Select all
<?php session_start(); ?>
<html>
<head><title>session test</head>
<body>
<p><?php echo 'time: ' . date('H:i:s'); ?></p>
<p><?php echo 'id:' . session_id(); ?></p>
<p><a href="<?php echo basename($_SERVER['SCRIPT_FILENAME']); ?>">reload</a></p>
</body>
</html>-
Stephen Bungert
- Forum Commoner
- Posts: 25
- Joined: Sat Feb 25, 2006 3:22 am
Volka, your test works now in Firefox but not IE - I only used IE before. Maybe it has something to do with IE?
In firefox the time stays the same and the id changes when I refresh the browser
In firefox the time stays the same and the id changes when I refresh the browser
Last edited by Stephen Bungert on Fri Oct 06, 2006 3:15 pm, edited 1 time in total.
-
Stephen Bungert
- Forum Commoner
- Posts: 25
- Joined: Sat Feb 25, 2006 3:22 am
I forgot to close the title tag.
If the session_id changes every time then a new session is started every time, new session->no data.
Does your browser reject all cookies?
Code: Select all
<?php session_start(); ?>
<html>
<head><title>session test</title></head>
<body>
<?php echo 'time: ', date('H:i:s'), ' | id:', session_id(); ?>
<br />
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">reload</a>
</body>
</html>Does your browser reject all cookies?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
-
Stephen Bungert
- Forum Commoner
- Posts: 25
- Joined: Sat Feb 25, 2006 3:22 am
session.save_path = "C:/Dokumente und Einstellungen/Stephen/Lokale Einstellungen/Temp"
; Whether to use cookies.
session.use_cookies = 1
I found this in the php ini.
there are lots of files in "C:/Dokumente und Einstellungen/Stephen/Lokale Einstellungen/Temp" that start with 'sess' so I guess these must be to do with the php sessions. I've never seen files named like this before.
; Whether to use cookies.
session.use_cookies = 1
I found this in the php ini.
there are lots of files in "C:/Dokumente und Einstellungen/Stephen/Lokale Einstellungen/Temp" that start with 'sess' so I guess these must be to do with the php sessions. I've never seen files named like this before.
-
Stephen Bungert
- Forum Commoner
- Posts: 25
- Joined: Sat Feb 25, 2006 3:22 am
Code: Select all
<?php session_start(); ?>
<html>
<head><title>session test<title></head>
<body>
<p><?php echo 'time: ', date('H:i:s'); ?></p>
<p><?php echo 'id:', session_id(); ?></p>
<p><?php echo 'name:', session_name(); ?></p>
<p><php echo 'use_cookie: ', ini_get('session.use_cookies'); ?></p>
<p><php echo 'use_only_cookie: ', ini_get('session.use_only_cookies'); ?></p>
<p><php echo 'session.use_trans_sid: ', ini_get('session.use_trans_sid'); ?></p>
<pre><?php print_r($_COOKIE); ?></p>
<div><a href="<?php echo $_SERVER['PHP_SELF']; ?>">reload</a></div>
</body>
</html>-
Stephen Bungert
- Forum Commoner
- Posts: 25
- Joined: Sat Feb 25, 2006 3:22 am