Page 1 of 1

Using session_start()

Posted: Wed Nov 20, 2002 5:45 pm
by srbarker
I'm trying to use session_start to store a few variables that are required by several pages on my website. However, it seems like if I access the same page twice it resets the PHPSESSIONID initializes the variables.

If before the session_start I set the session_id to session_id("1234") it works fine.

Any ideas?

Posted: Wed Nov 20, 2002 5:47 pm
by JPlush76
can you paste the top part of you code in so we can look?

session_start()

Posted: Wed Nov 20, 2002 5:57 pm
by srbarker
JPlush76 wrote:can you paste the top part of you code in so we can look?

at the top of get_coaches_user_password.php

<?php

/* start a session */

session_id("1234");
session_start();
session_register('theuser');
session_register('thepassword');

?>

at the top of validate_user_password.php


<?php

session_id("1234");
session_start();

?>

it does not work if I remove the session_id("1234")

Thanks, Steve

Posted: Wed Nov 20, 2002 6:04 pm
by JPlush76

Code: Select all

&lt;?php
session_start();

$_SESSION&#1111;'theuser'] = 'jplush76';
$_SESSION&#1111;'thepassword'] = 'pass';


echo $_SESSION&#1111;'theuser'];
?&gt;
see if that works, just in case.. session_start() has to be at the VERY top of your script, even before any html or anything

More session_start()

Posted: Wed Nov 20, 2002 9:50 pm
by srbarker
Hmmm...maybe I don't understand sessions...I thought it would maintain the same session_id across multiple accesses of the same page as long as it was called from the same client / browser?

What I have noticed is if I load the same page twice with session_start() I get a new session_id....if I go from one page to the next and call session_start() at the top of each page it works fine.

A setting in my php.ini ???