Re: [PHP] How to use multiple cookie statements
Can you use my above values to show me what you are talking about? "Matt M." <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > setcookie("cookie[name]","$_POST['name']", time()+86400) > > setcookie ("cookie[email]","$_POST['email']", time()+86400) > > setcookie ("cookie[bgcolor]","$_POST['bgcolor']", time()+86400) > > setcookie ("cookie[tcolor]", "$_POST['tcolor']", time()+86400) > > > > ?> > > > you could try this: > > setcookie ('values', serialize($_POST), time()+86400); > > then when you want to retrieve it use > > $values = unserialize($_COOKIE['values']); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to use multiple cookie statements
* Thus wrote Jason Barnett: > Or if you feel lazy... then you can use serialize / unserialize. I'll be even lazier... setcookie('foo[bar]', 'is ok'); setcookie('foo[qaz]', 'is better'); // after cookie is set. $myFoo = $_COOKIE['foo']; print_r($myFoo); Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to use multiple cookie statements
> I have to use cookies, since I am taking a class and it dictates that we > use cookies, but I can't email my instructor since she never responds. > So how do I use a cookie to record multiple values? Help would be > appreciative.a A few options: use multiple cookies, e.g. setcookie('cookie_a'), setcookie('cookie_b'), etc. Jordi's suggestion is also good, though I would suggest using serialize() to make a single string out of your values, like this: serialize(array('name1' => 'value', 'name2' => 'value'). Or, use PHP's built-in session support. The cookie stores a unique ID, whie the actual values are stored on the server. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to use multiple cookie statements
> setcookie("cookie[name]","$_POST['name']", time()+86400) > setcookie ("cookie[email]","$_POST['email']", time()+86400) > setcookie ("cookie[bgcolor]","$_POST['bgcolor']", time()+86400) > setcookie ("cookie[tcolor]", "$_POST['tcolor']", time()+86400) > > ?> you could try this: setcookie ('values', serialize($_POST), time()+86400); then when you want to retrieve it use $values = unserialize($_COOKIE['values']); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to use multiple cookie statements
Or if you feel lazy... then you can use serialize / unserialize. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to use multiple cookie statements
Ronald "The Newbie" Allen wrote: aHere is my code... ?> I have to use cookies, since I am taking a class and it dictates that we use cookies, but I can't email my instructor since she never responds. So how do I use a cookie to record multiple values? Help would be appreciative.a As the standard says, 1 cookie = 1 value, no way to have more than one value in a cookie. But you can think about some workarounds, a quick example just to give you an idea: $cookie = implode(':', $array) Here you will have all values from the array in the cookie, and using : as a separator. To reverse the values: $values = explode(':', $cookie) and here you will have all values in the array $values, starting with index 0. Of course, in this way you can only set values, not the array keys. Look in the manual for implode() and explode() and see if is usefull for you. Regards, Jordi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to use multiple cookie statements
aHere is my code... I have to use cookies, since I am taking a class and it dictates that we use cookies, but I can't email my instructor since she never responds. So how do I use a cookie to record multiple values? Help would be appreciative.a -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php