Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problems unloading a session

    PHP Code:
    <?php
    session_start
    ();
    echo 
    phpversion();
    header("Cache-control: private"); //IE6 Fix

    if (($_SESSION['userstatus'] = 'admin')) {
        echo 
    'Access Allowed';
        
    $_SESSION['userstatus'] = FALSE//or use = ''
    } else {
        echo 
    'Access Denied';
    }
    ?>
    My php version is 4.3.3. I'm prettying sure the syntax for unloading the session is correct but it's not unloading... I have no clue. I also tried: session_unregister('userstatus'); and unset($_SESSION['userstatus']); but none of them seem to want to work. Can anyone help me with the right syntax?

    -Thanks,
    Rich

  • #2
    Regular Coder
    Join Date
    Jul 2003
    Location
    New Zealand
    Posts
    435
    Thanks
    1
    Thanked 0 Times in 0 Posts
    $_SESSION['userstatus'] = '';

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    if (($_SESSION['userstatus'] = 'admin')) { 
    I think you have an error in there - don't you rather want to do a comparison than an assignment, like

    PHP Code:
    if (($_SESSION['userstatus'] == 'admin')) { 
    ? Because otherwise you always set the userstatus again.
    De gustibus non est disputandum.

  • #4
    New Coder
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mordred
    PHP Code:
    if (($_SESSION['userstatus'] = 'admin')) { 
    I think you have an error in there - don't you rather want to do a comparison than an assignment, like

    PHP Code:
    if (($_SESSION['userstatus'] == 'admin')) { 
    ? Because otherwise you always set the userstatus again.
    I keep on forgetting if you need to check something you need two equal signs. Thanks!

    -Rich


  •  

    Posting Permissions

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