Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 4th, 2003, 08:05 AM
Authorized User
 
Join Date: Jun 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default php and cookies

Using javascript I have written a cookie with several comma seperated values. Is it possible to use php to read the cookie, I want to loop through all the values stored in the cookie? Is it possible? does anyone know how to do it?
 
Old July 4th, 2003, 10:04 AM
Authorized User
 
Join Date: Jun 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to natmaster Send a message via AIM to natmaster Send a message via MSN to natmaster
Default

if i undestand what your saying and you have one cookie variable that is a string then this is how you would access (replace all instances of VARNAME with your cookie variable name):

$string=$_COOKIE[VARNAME]; //copies the cookie variable to a string
$array=explode(",",$string); //seperates the string into array elements

then you have an array with each element, if you want to access those then run a foreach:
foreach($array as $element) {
  //do stuff
}

----------------------------
http://aeonofdarkness.com
 
Old July 7th, 2003, 07:22 AM
Authorized User
 
Join Date: Jun 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cheers, thats exactly what I was looking for





Similar Threads
Thread Thread Starter Forum Replies Last Post
Would this php cookies embedding method work? Puripong PHP How-To 0 November 8th, 2007 10:34 AM
Should I use cookies?? Help Tee88 Classic ASP Basics 3 January 21st, 2005 12:33 AM
Help!About Cookies jelsen ASP.NET 1.0 and 1.1 Basics 2 September 9th, 2003 08:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.