Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Thanked 0 Times in 0 Posts

    Can't Get Session to Work!

    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>";
    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?!?!



  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,662 Times in 2,631 Posts
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts