"Stijn Goris" <mepistohotmail.com> wrote in message
news:3f622bb2$0$24129$ba620e4creader1.news.skynet .be...are> hi all,
> Trying to get those cookies to work but they wont...
> Doing this. Have a page login.php wich tests the user and pass. If theyYour problem is likely due to a limitation to cookies, not php.> correct a cookie is set with one variable like this: setcookie
> ("cookieUser", $user);
> then the browser is sent with header("Location: spelersPage.php"); to
> another page.
> I there try to read the cookievariable cookieUser on the spelersPage.php
> like this.
> $test = $_COOKIE["cookieGebruiker"];
> echo "|$test";
> without any succes. Someone has an idea. The page is im my Thrusted sites
> kind regards
A refresh has to have occured before your cookie becomes available to your
environment thus if you were to refresh your browser a couple of times you
should get your cookie. If not, as a test, I tend to use phpinfo(); alot
when doing various tests on form and cookie variables... Try writing the
following few lines to a php script file of its own (call it cookieTest.php
for our example).
// For our test, our cookie will be the words "hello world" followed by the
eleven digit timestamp generated by time();
$ourCookie="hello world" . time();
print("<br>1 = The cookie we just set is $ourCookie<br>");
print("<br>2 = However the cookie that is already baked is:
View this code in a page of its own... refresh the page a few times and
examine the values that are output - and while you're at it, examine the
output of phpinfo();.
I would expect that you should find something like
1 = The cookie we just set is hello world12345678901
2= However the cookie that is already baked is:
The next time your refresh your browser, you should find the output
something like the following
1 = The cookie we just set is hello world12345678911
2= However the cookie that is already baked is:hello world12345678901
Note that the cookie the first time was sent to the browser but could not be
read yet (until you re-freshed the browser).