Results 1 to 2 of 2
Thread: Cookie Scoop
Feb 16, 2003, 11:51 #1
I want to check if the cookie is set or not, because as its mentioned in the manual:
so I have the following scenario:
In the index page I check if a cookie is set or not, if its not set, just set a new cookie and then redirect to a page called "TestCookie.php" to test the cookie if it was set successfully or not, but the problem is: Im always after testing the cookie it gave me that its not set, so where is the error in my scripts.
Cookies will not become visible until the next loading of a page that the cookie should be visible for.
Note: I noticed that if the index.php is in the same directory with TestCookie.php and Cookies.php it works fine, but if index.php is in an upper directory, it will not work! Is the problem with cookie's path? Although I set it "/" to be at the home directory to be viewable to all directories.
Here is my scripts:
Note that index.php at the root while (TestCookie.php and Cookies.php) in the "User" directory under the root.
$GuestSID = $HTTP_COOKIE_VARS[GuestSID];
echo "Not Set";
Header ("Location: /index.php");
Header ("Location: /Users/TestCookie.php");
$GuestSID = mt_rand();
setcookie ("GuestSID", $GuestSID,time()+900, "/", ".127.0.0.1", 0);
Please Help ME.HaVe a GooD DaY
Feb 16, 2003, 18:17 #2
talk about spaghetti code, try an easier example...
index.php, checks/sets cookie, has link to doescookieexist.php that checks for cookie?
cookies being header info and using header to redirect is problematic, and what do you gain by this?