Score: 0.00 Votes: 0
rate this

PHP setcookie(); problems

Starter: Diz-X Posted: 22 years ago Views: 1.5K
#1359
Lvl 25
I got some problems with the setcookie(); On some browsers the cookie isn't set, or when it is set it can't be removed.

the command i use to set the cookies:
$expire = time() + 60*60*24*365;
setcookie("UserId", $login[1], $expire, "/", $HTTP_HOST,0);

or remove them:
setcookie("UserId", "", time()-3600, "/", $HTTP_HOST,0);

What is the problem? Any cookie experts in da house?
#1360
Lvl 12
I think cookies are the worst things in PHP :/
Anyway: your code should be working fine.. Are you printing some date in PHP/HTML/Whatever before you do the cookies?
#1361
Lvl 25
The code starts with php no spaces or anything in frond of them.. This problem i got since php 4. Php3 was doing cookies very nicely, but all the problems started with PHP4 that some cookies aren't set that well... If you maybe allready noticed, a lot of things on this website work with cookies...
* This post has been modified : 22 years ago
#1362
Lvl 12
Hmmm... And there are no errors on screen?
You don't print _anything_ with PHP before you set the cookies? (so not an 'echo', 'print', 'header', etc command)
#1363
Lvl 25
I know, if you allready send text or even a space, you get a error from PHP. But the problem is that on some computers the cookies are set and can´t be removed anymore.. and on other computer work perfectly.. i think this is a bug of php. Not the scripting... So maybe i done something wrong in my setcookie(); ...
#1364
Lvl 13
I read something in a comment to the setcookie() on php.com which said the problem is with the browser reading the site - not the script itself. there was an example script which could tell if the client thought the cookie were set or not, but it did not give a solution just told the client that it should install another browser.

Sorry to be so diffuse but I don't feel like finding it again right now.
* This post has been modified : 22 years ago
#1365
Lvl 25
Hmm.. i know this problem is only with 4 or less browsers. But the problems is with IE 6 and IE 5, got no reports of other browsers (mozilla, opera)
#1366
Lvl 12
Maybe a 'wrong' configged computer?
I don't know if this is possible, but what if the user has no rights to remove files, then a site like this also can't delete files..
#1367
Lvl 13
Well or simply have messed their cookies-settings up in IE's setup
* This post has been modified : 22 years ago
#1368
Lvl 22
i duno much about php but someone told me to be carefull about other sites pverwriting mine´s cookies

so i choosed a weird name for it so it would nt be overwrited
cheers
#1369
Lvl 12
Hmm, I don't think that really happens. 'Cause I don't know why someone wants to overwrite cookies..
#1370
Lvl 12
cookies mjam but i dont like this cookies it fils your hard drive with it