SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: Cookies, can't read 'em
Threaded View
-
Jul 8, 2000, 14:28 #1
- Join Date
- Jul 2000
- Posts
- 1
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm having a hell of a trubble with this. There does not seem to be much in the way of PHP cookie examples around, so I must be missing somethin very basic. Here's the code...
This gets form input in the form of two arrays, stick 'em together, then sets the cookie...
<?php
$stock_string = implode (",",$stock_choice);
$feed_cookie = implode (",",$feed_choice);
$feed_cookie = $feed_cookie . "," . $stock_string;
setcookie("feed_cookie", $feed_cookie, time() + 3600);
?>
This is a section of code I would like to read the cookie, it reads the cookie in, then breaks a few chunks off the end....
$HTTP_COOKIE_VARS["feed_cookie"];
if (strlen($feed_cookie) == 0) {
$cookie_stat = 0;
} else {
$cookie_stat = 1;
$stocks = substr (strrchr ($feed_cookie, ","), 1);
$feed_cookie = substr ($feed_cookie, 0, (strlen ($feed_cookie) - strlen($stocks)));
$stocks2 = substr (strrchr ($feed_cookie, ","), 1);
$feed_cookie = substr ($feed_cookie, 0, (strlen ($feed_cookie) - strlen($stocks2)));
$stocks3 = substr (strrchr ($feed_cookie, ","), 1);
$feed_cookie = substr ($feed_cookie, 0, (strlen ($feed_cookie) - strlen($stocks3)));
}
But, alas, it does nothing because it cant see the cookie(?).
What am I missing?
[This message has been edited by jake (edited July 08, 2000).]
[This message has been edited by jake (edited July 08, 2000).]
Bookmarks