php - Cookie does not set -
i have cookie not set on remote server, works find locally. no error messages, var_dump gets me null, echo blank.
<php setcookie('ymp','14', time()+3600); session_start(); ?>
i can set javascript cookie fine. opening tag line 1 of page.
any ideas
thanks gary
on edit
i have comments posted below, 3 file process.
page 1 set cookie, above.
page 2 have debugging
<php var_dump($_cookie['ymp']); echo'<br />'.$_cookie['ymp'];?>
page 3, , again worked locally have
<?php if($_cookie['ymp']!=='14') {die('sorry, have not had delightful little pastry yet.... try again.');}
?>
i set js cookie, , changed code reflect different cookie name , worked fine.
i reset time +86400, because of 2 hour time difference server, though don't think required.
thanks help
gary
you can't read value of cookie until new page request made. because value of cookie data sent page request. isn't available access value until after set , new page request made.
also, session_start()
has no effect on cookies. 2 different things. (sessions typically use cookies store session id irrelevant).
Comments
Post a Comment