Weird Session Problem!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
guvna69
Forum Newbie
Posts: 1
Joined: Sat Jan 29, 2005 3:53 am

Weird Session Problem!

Post by guvna69 »

I have this weird problem with PHP version 2.3.9. I have

Code: Select all

<?php session_start (); ?>
on my page and every time I refresh the page a new session is made. Which means refreshing 5 times produces 5 new sessions. I have tried firefox & internet explorer with session cookies enabled and it still does the same thing. I have googled and found nothing.

I am wondering if it is a PHP.ini thing. Can anyone help?
hunterhp
Forum Commoner
Posts: 46
Joined: Sat Jan 22, 2005 5:20 pm
Contact:

Post by hunterhp »

2.3.9? Why don't you just upgrade to version 4.3 or 5.0?

And I don't know about that far back of php, I just started.
thegreatone2176
Forum Contributor
Posts: 102
Joined: Sun Jul 11, 2004 1:27 pm

Post by thegreatone2176 »

you could try...


if (!session_id()) {
session_start();
}

that checks if there is a session id and if there isnt it one it starts

and you really should update your php version also
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Could you show us the session variable/variables you are using!. I don't think it has anything to do with the PHP configuration file but instead something with your code.
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

i think the php version was a typo. must be 4.x because sessions didnt exist until then.

try this. put it in a NEW php file with no other code in it.

if the session id changes everytime you refresh the page, then there is a problem

if you get any errors, please cut and paste them for us.

Code: Select all

<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);

session_start();
echo session_id();

if (!isset($_COOKIE&#1111;session_name()])) &#123;
    echo '<br> browser did not send cookie';
&#125;
?>
Post Reply