Re: Multiple sessions open at same time, is it possible? [ Solved, thankyou !]
| From: | Richard | Date: | Sun, 02 Mar 2008 17:12:08 +0000 |
| Subject: | Re: Multiple sessions open at same time, is it possible? [ Solved, thankyou !] | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-270838@lists.php.net to get a copy of this message | ||
Stut a écrit :
On 2 Mar 2008, at 16:32, Richard wrote:|Stut a écrit :Eh? What's in $_SESSION['cart']['item_number']? You might want to consider one of the following depending on what's in that array element... unset($_SESSION['cart']['item_number']); unset($_SESSION['cart'][array_search($itemtoremove, $_SESSION['cart'])]); unset($_SESSION['cart']['item_number'][array_search($itemtoremove, $_SESSION['cart']['item_number'])]); At the very least it would be better to use null rather than array(), but actually removing the item from the array would be my recommendation. -Stut Sorry I went back to where I read that I should use =array(); and I miss read an instruction which was : http://fr3.php.net/unsetJust curious... why are you setting the password to an empty array? You'd probably be better off unset'ing it so you can use isset to check for it.Oh right ! :) Yes you're right about the array, I used it by mistake, as to reset a value in $_SESSION[cart] , ie : $_SESSION['cart']['item_number'] I had to do $_SESSION['cart']['item_number'] = array(); as unset would anly work for unsetting the whole cart and not just one item, but yes it would be best to use unset for $_SESSION['password'] !
|Quote from http://fr.php.net/session_unset "Do NOT unset the whole $_SESSION with unset($_SESSION) as this will disable the registering of session variables through the $_SESSION superglobal." So basically don't do: unset($_SESSION) Instead do: $_SESSION = array();|So no need for setting my session variables to array()... |