PHP ending sessions(different ways) i dont understand

后端 未结 2 918
轻奢々
轻奢々 2020-12-18 09:53

I\'m trying to understand sessions and how some of the functions to end them work. I\'ve gone to different sites/and even here on SO and, well essentially, nothing is workin

相关标签:
2条回答
  • 2020-12-18 10:17

    You have to start a session in order to end a session. I recommend taking a look at... http://php.about.com/od/advancedphp/ss/php_sessions_3.htm

    // you have to open the session to be able to modify or remove it 
    session_start(); 
    
    // to change a variable, just overwrite it 
    $_SESSION['size']='large'; 
    
    //you can remove a single variable in the session 
    unset($_SESSION['shape']); 
    
    // or this would remove all the variables in the session, but not the session itself 
    session_unset(); 
    
    // this would destroy the session variables 
    session_destroy(); 
    
    0 讨论(0)
  • 2020-12-18 10:18

    You are missing a session_start() at the top of your logout page. It's trying to modify a session that doesn't exist!

    0 讨论(0)
提交回复
热议问题