Gossamer Forum
Home : General : Internet Technologies :

Cookie Array Question

Quote Reply
Cookie Array Question
I have set my cookies as an array so that all the info is stored in 1 cookie.

Code:


<?php setcookie("ptdetails[user]", "$user", time()+60*60*24*30, "/");
setcookie("ptdetails[pword]", "$pword", time()+60*60*24*30, "/");
setcookie("ptdetails[usertype]", "$usertype", time()+60*60*24*30, "/");
setcookie("ptdetails[secure]", "$secure", time()+60*60*24*30, "/");
setcookie("ptdetails[pagestyle]", "$pagestyle", time()+60*60*24*30, "/");

header('Location: index.php') ?>


Now I am trying to get the information out of the cookies and so far having no luck.

Code:


if(!isset($user) OR !isset($pword) OR !isset($usertype) OR !isset($secure) OR !isset($pagestyle)) {

print_r($_COOKIE);

echo("<hr />");

foreach ($_COOKIE['ptdetails'] as $name => $value) {
echo "$name : $value <br />\n";

$value = $ptinfo[$name];;

}

echo("<hr />");

print_r($ptinfo);


}


I've looked through the php documentation on both cookies and arrays but I cannot find the answer to the problem I'm having. Anyone's help would be appreciated.


By the way. When I tested it using the print_r($_COOKIE); and the echo "$name : $value <br />\n"; I got the following:

Quote:


Array ( [ptdetails] => Array ( [user] => Josh [pword] => something [usertype] => admin [secure] => true [pagestyle] => default ) )


user : Josh
pword : something
usertype : admin
secure : true
pagestyle : default

Last edited by:

JoFrRi: Nov 4, 2003, 9:44 AM
Subject Author Views Date
Thread Cookie Array Question JoFrRi 7573 Nov 4, 2003, 9:40 AM
Thread Re: [JoFrRi] Cookie Array Question
Andy 7245 Nov 4, 2003, 3:22 PM
Thread Re: [Andy] Cookie Array Question
JoFrRi 7188 Nov 4, 2003, 7:42 PM
Thread Re: [JoFrRi] Cookie Array Question
Andy 7263 Nov 5, 2003, 1:27 AM
Post Re: [Andy] Cookie Array Question
JoFrRi 7173 Nov 5, 2003, 9:42 AM