son Posted October 7, 2009 Share Posted October 7, 2009 I use sessions for a shopping cart and for a dedicated user area on same website. On logout page of dedicated user area I have: $_SESSION = array(); // destroy the variables session_destroy(); // destroy the session itself setcookie (session_name(), '', time()-300, '/', '', 0); // destroy the cookie As this destroys all session data this is not what I want. I want only to destroy the session data relevant to dedicated user area. I use $_SESSION['first_name'] for login/logout status of user area and $_SESSION['cart'] for shopping basket. How do I only destroy first_name?Son Link to comment Share on other sites More sharing options...
justsomeguy Posted October 7, 2009 Share Posted October 7, 2009 You can use unset to delete a variable, if you unset an array element it will remove the element from the array. Link to comment Share on other sites More sharing options...
son Posted October 8, 2009 Author Share Posted October 8, 2009 You can use unset to delete a variable, if you unset an array element it will remove the element from the array.Use now:unset($_SESSION['first_name']);as suggested. Does the trick:-)Cheers,Son Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.