Scoochi2
New Member
- Messages
- 185
- Reaction score
- 0
- Points
- 0
I have a problem within one of my programs where I cannot set cookies at all.
I have used the above code, and the page will show 123, as expected. However, there is no cookie!
At first I thought maybe I'm not allowed to set cookies
so I created a new page that looked like the following:
Again, it outputs the expected 123, but this time it does set a cookie.
Am I missing something here?
BTW, no header information was sent prior to the cookie, and PHP gives no error.
Code:
[...]
if (conditions)
{
$cookiedata = '123';
setcookie("cookie1", "$cookiedata", time()+604800, '/');
echo "$cookiedata";
}
[...]
At first I thought maybe I'm not allowed to set cookies
so I created a new page that looked like the following:
Code:
<?php
$cookiedata = '123';
setcookie("cookie1", "$cookiedata", time()+604800, '/');
echo "$cookiedata";
?>
Am I missing something here?
BTW, no header information was sent prior to the cookie, and PHP gives no error.