I want to save a cookie for a visitor. I use the code below but it seems it won't work for me. Please guide me where I am wrong
<script type="text/javascript">
if(!isset($_COOKIE['visited_alreadyxxx']))
{
setcookie('visited_alreadyxxx' , 'true' , time()+60*60*24*7*365);
alert("hi");
}
</script>
Edit : sorry for above code , does below code work correctly ?
<?php
if(!isset($_COOKIE['visited_alreadyxxx']))
{
setcookie('visited_alreadyxxx' , 'true' , time()+60*60*24*7*365);
?>
<script>alert("hi");</script>
<?
}
?>