...

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



RikoGuy
01-05-2007, 02: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.

session_start();
$sesUser = $uName;
session_register('sesUser');
echo "session registered";

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

$_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?!?!

thanks!

eric

Fou-Lu
01-05-2007, 03:09 AM
AHHHH!


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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum