...

View Full Version : cookie problem !



Trki
02-16-2012, 08:46 PM
Hi guys :( :( i dont know why but i found a problem at my webpage a few minutes ago. When i log in it do not create a cookies. i was trying to found the broken code because i didnt have idea where could be a problem... i deleted all from the login script file and in file is now just:

setcookie("web_user", "failure");

and it do now create a cookie!!! but when i try:

setcookie("web_user", "failu re");

it works... so my question ... WTF??? :P

mlseim
02-16-2012, 09:18 PM
You're setting a cookie without an expire date,
so I think it expires when the browser closes,
much like SESSION. Try giving it an expiration date
and I bet it will work for you ...

setcookie("web_user", "failure", time()+604800); // one week

Also, you can't set a cookie and read it in the same
script without at least one page refresh. It's the
page loading that sets the cookie (with the HTTP request header).


.

Trki
02-16-2012, 09:35 PM
You're setting a cookie without an expire date,
so I think it expires when the browser closes,
much like SESSION. Try giving it an expiration date
and I bet it will work for you ...

setcookie("web_user", "failure", time()+604800); // one week

Also, you can't set a cookie and read it in the same
script without at least one page refresh. It's the
page loading that sets the cookie (with the HTTP request header).


.

no i had it there i just removed because i wanted extremly easy for find a error.

Hm... yea i know that i have to refresh page ... but i have following login:

(take nick, pass, check db if exists ( everything working well ok ) and then:

if is match in DB

setting session
update something in DB
setcookie

then i refresh a page ... session and db is updated but cookie is not set up

Trki
02-16-2012, 09:40 PM
i have idea... could you recommend me some tool with which i check what is currently sending me in HTTP header to server or something like that. ? or something for scan php errors/blocks maybe something is blocking together.

mlseim
02-16-2012, 10:28 PM
Post your exact code ... but X-out any passwords.
The script where the cookie is set.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum