Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookie doesn't set on the server 1

Status
Not open for further replies.

DaSe

Programmer
Feb 14, 2008
149
GB
Hello to all. Yesterday I came across an issue where I can't execute a cookie for some reason on the server. It works locally though without no problems. The domain's path is "/tmp" for session_path. Here's the code. Thanks for comments:

Code:
if (!isset($_COOKIE['TestCookie'])) { 
$vote_com2 =  mysqli_query($connect,"UPDATE news SET up = '".$upv."' WHERE news_id = '$idn'" );
 setcookie("TestCookie", $idn, time()+3600,"/",".mydomain.net"); 
}

 
So what happens? Do you get an error? Does the cookie simply not set?

What is $idn? Is it set?

Why do you set $vote_com2 but never use it?

Give us something to work with.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Hi Phil,
ok - I get no errors on error_reporting(E_ALL). Secondly, the code works perfectly locally. When uploaded on the server it doesn't set the cookie for some reason. For now I replaced the cookies with setting $_SESSION instead - but that is only for as long as the browser on of course. The code seems fine - the cookie should be set upon first time query for 1h - but doesn't work on server. $idn is the variable that is passed from $_POST it's used for voting. So each voting item has its own $idn. Lastly - $vote_com2 never used ? It is executed correctly when user has not 'set' the cookie...
K.R.

 
My bad, I didn't see your query was an update, thought it was standard select.

Browser set to allow cookies ? Allow cookies from that server?

So what are you doing if the cookie is set?
Your codes set's it if its not, but then what should happen if it is?

How are you checking for that?

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Hi Phil,
Sorted. The issue is about the time o the server and my location which is about a 4h difference. That's why a cookie set for 1h didn't work. So I need to re-set to a longer expiration date...hope it'll solve the problem. Thanks a lot.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top