i want to set cookies to the webpage, the webpage with extension .php has this content
<?php
setcookie("engineer","engineer",time()+3600);
?>
<html>
<img src= "image3.jpg" height="300" width="300"/>
</html>
i created a apache2 server in my ubantu virtual machine, and placed the above file with name test.php
in the /var/www/html
folder and tried to access the website, the website got opened but the cookie was not set :( i don't the reason why cookie has not set. i tried some answers from stackoverflow but still not able to set cookie anyone help me in this
Here is what i tried
added the '/' for path
setcookie("engineer","engineer",time()+3600,'/');
but still not able to setcookie
uninstalled and reinstalled the apache2 server but still same issue.
also tried by removing time() in that line
setcookie("engineer","engineer",3600);
My Answer:
setcookie("user", "John Doe", time() + 3600, "/");
?>
Rate this post
4 of 5 based on 1695 votesComments