/    Sign up×
Community /Pin to ProfileBookmark

Cookie problem connected to PHP?

I write cookies using PHP:

================================

if ($pass==$password && $id2==$id) {

setcookie(“remember”,”yes”,time()+82800,”/”,”.mydomain.com”,0);

setcookie(“user”,$id,time()+82800,”/”,”.mydomain.com”,0);

setcookie(“pass”,$password,time()+82800,”/”,”.mydomain.com”,0);

setcookie(“pay”,$pay1,time()+82800,”/”,”.mydomain.com”,0);

$vaia=”Location: enter.php”;

} else {

$vaia=”Location: retry.php”;

}

mysql_close;

header($vaia);

========================================

Problem: one in every so many people doesn’t get the cookie written to their PCs. There’s just NO cookie, while other sites seem to work fine. I managed to test in a couple of cases, no firewalls or anything else that could have caused this problem.

Re-installing the browser/operating system so far seems to solve the problem.

Does anyone have this experience?

Is there a solution?

This drives me NUTS : (((

PLEASE HELP

Mike

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@redijediMar 28.2004 — As nice as cookies can be, they're unreliable at best. Its difficult to say what could be happening in your case. Maybe they are blocking cookies, certain kinds of cookies, or specific cookies. It could be through a firewall (though you said no) or through the settings in the browser.

The best way to handle persistent data is through a database. You can use sessions to manage a session table and hold all of the data there. Then you'll alleviate the need to set cookies which can easily be messed with by the user. The next best solution is to store the cookies server side through the session itself. This is not a bad idea at all, just not as good as a dedicated database solution because it requires less IO calls altogether.

I know that's probably not an answer, but it's my suggestion.
×

Success!

Help @MikeNL spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...