coockie notify?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
thomasd1
Forum Commoner
Posts: 80
Joined: Sat Nov 22, 2003 2:48 pm
Location: Belgium

coockie notify?

Post by thomasd1 »

how can i notify a visitor on my site, that he must enable his browser to accept coockies?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

You will need to set a temp cookie and see if it exists on the next page load/refresh.

On the first page you might have..

Code: Select all

<?php
setcookie("tempName","aValue", strtotime("+1 hour", time()));
?>
On the second page you might have..

Code: Select all

<?php

if(isset($_COOKIE["tempName"]))
{
     echo "Cookies are enabled.";
     setcookie("tempName", "", strtotime("-1 hour", time())); // deletes the temp cookie
}
else
{
     echo "Cookies are disabled. TURN THEM ON!";
}

?>
Post Reply