FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


how do you destroy all sessions except one?





Denvis
I wanna add an additional feature to my hangman game. Each time the user correctly guesses a word, their score is added by 1. However, the problem is each time the user wins they're re-directed to index.php and that resets the counter. How do I make it so that whenever it goes back to index.php, it doesn't reset but at the same time everything else does?
thnn
Depending on how you are currently resetting things, if you are unsetting the $_SESSION variable and then using it again, then I suggest changing from that, and specifically zeroing or resetting only the parts of the $_SESSION you want to change. For instance if you want to reset the guesses stored in say $_SESSION['guesses'] then just use $_SESSION['guesses'] = new array();

And then just leave your counter as it is.
rickylau
Maybe if you would like to reset all except the specified one, simply store it somewhere before resetting, after that store it back to the original variable.
sonam
Instead of unset $_SESSION maybe you can use foreach loop for reseting one by one except this what you need for future.

Sonam
Related topics
STEVEN WRIGHT QUOTES
E-Cards with PHP & MySQL
php sessions
Top Chinese General Warns US Over Attack
Sessions
The downfall of american society
PHP: Sessions and Cookies
Christopher Walken for President??
CSS/Layout Help Please!
future of instant messaging
destroy\unset sessions?
Authentication Module
10 Bizarre Experiments
Storing A Lot of Values Using Sessions
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.