View Full Version : Can't Get Session to Work!

01-05-2007, 03:57 AM
hello everyone today is the first time i've tried using sessions and i'm having some trouble getting it to work for me. i've setup my login script to start and register a session if the login was successful.

After registering the session i print it out to make sure it's working. this is what my code looks like.

$sesUser = $uName;
echo "session registered";

echo $_SESSION['sesUser'];
echo "<br>";
echo session_is_registered('sesUser');
echo "<br>";

$_SESSION['sesUser'] successfully prints it's variable and ..."is_registered" shows the number one (which i'm assuming is "true") but $PHPSESSID yields nothing and when i try to print my session (sesUser) from another page I get nothing... why?!?!



01-05-2007, 04:09 AM

Before PHP 4.3, if you are using $_SESSION and you have disabled register_globals, don't use session_register(), session_is_registered() or session_unregister(). Disabling register_globals is recommended for both security and performance reasons.

session_register is deprecated. Do not use it anymore. Only stick with $_SESSION if you have it available. Watch the default configurations of sessions as well - they may not be what you want (requiring cookies and all).
Next, I assume you are looking for SID instead, thats an appendable session id. Doesn't matter anyway, it won't register without having required cookies set to off. PHPSESSID if I'm not mistaken is only the value of your cookie session IF you have not chosen to rename it. In that case, its located in the $_COOKIE (or $_REQUEST) superglobal, and cannot be accessed by its name unless your register_globals are enabled - which you shouldn't be using even if they are.
Hope that helps ya.