1

I set a cookie and then check if exist like this

if(isset($_COOKIE["fan"])) { //Do Nothing } else { $cookie = "yes"; $expire=time()+60*60*24*30; setcookie("fan", $cookie, $expire); include_once("../inc/functions.php"); echo fan_page(); } 

When I test on my local machine, it works, but when i upload to production server, it doesn't work.

What am I doing wrong?

Thanks In Advance!

Marc

2 Answers 2

2

You probably need to set the domain for the cookie. Locally it defaults, but in production you may come across some issues if it's not set explicitly.

See the arguments for setcookie; http://www.php.net/manual/en/function.setcookie.php

I also suggest looking in your browser cache to see if it is being set.

Sign up to request clarification or add additional context in comments.

Comments

0

A cookie set for one path/hostname may override a cookie set for another path/hostname even if it is newer.

For instance, if there is already a cookie set for "www.example.com" and you set one for "example.com", when you read back the same cookie you'll get the one that was set for "www.example.com".

Try setting the cookie for the more specific hostname.

This may be part of the issue.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.