Home : General : Internet Technologies :

General: Internet Technologies: Cookie Array Question: Edit Log

Here is the list of edits for this post
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

Edit Log: