Thread: Resolved Checking for a cookie?
View Single Post
Old 11-30-2012, 02:30 PM   PM User | #2
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,890
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
as it happens the code works for me on firefox, but any issues are possibly down to the fact that setcookie expects a string value as the value, not a boolean (true/false) so if you used !== then you check might fail

so really you should
PHP Code:
function check_cookie() {
    if(
$_COOKIE['test'] != "someval"){
        echo 
'setting cookie';
        
setcookie("test""someval"time()+3600);
    }

though you could just as easily test if the cookie is set .. if(isset($_COOKIE['test'])){etc
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Users who have thanked firepages for this post:
Oatley (11-30-2012)