Reply
Old 01-30-2005, 06:43 PM Cookies
HitRaj47's Avatar
Extreme Talker

Posts: 177
Location: GA
i am a bit of a n00b at PHP, but id like to know if it's possible to store more than one variable in a cookie?

if so, whats the code?

thanks.
HitRaj47 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 01-30-2005, 07:17 PM
ACJavascript's Avatar
Humble Mod

Posts: 548
Location: CT, USA
Yes you can store more then one variable, but you will be required to extract the variables when accessing the cookie.

Example (Setting 1 cookie with 3 variables):

$info="field1,field2,field3";
setCookie("myfields",$info,time()+86400,".yourdoma in.com");

When we call the cookie
echo $_COOKIE[myfields]
It will print "field1,field2,field3"

So now we have to seperate the values. I will use explode for this.

$new_info=explode(",",$_COOKIE[myfields]);
foreach($new_info AS $new_field){
echo $new_field."<BR>";
}

You can also access it in an array.
echo $new_info[0];
echo $new_info[1];
echo $new_info[2];


__________________
CYTech-services.com - 100 Satisfied Customers - Custom Programming and Web Development
ACJavascript is offline
Reply With Quote
View Public Profile Visit ACJavascript's homepage!
 
Reply     « Reply to Cookies
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11093 seconds with 12 queries