FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Cookies not getting set





rohan2kool
Now cookies have always been a troublesome part for me.. and this time it's worse.

I'm trying to set a cookie this way:

setcookie("nuetron_SFXB_session", $sid, MAX_TIME);

where $sid = some text, but not "" and MAX_TIME is the time a cookie should stay alive... which is also not "" in any case

Now the problem is no matter how many times i execute this page, the cookie is not getting set Sad Sad

But it's not a browser problem also, on my server phpMyAdmin easily sets it's cookies even after i delete them once. Also, no text is outputted before saving the cookies, so there's no question of the header error too (even if there was it should alert me, but it doesn't). So.. what is the problem here?

Even providing all the parameters doesn't help:

setcookie("nuetron_SFXB_session", $sid, MAX_TIME, "/", "localhost", 0);

Please help... thanks a lot in advance.
SlowWalkere
First, if you're just storing session data, why not use $_SESSION variables instead?

But, if you want to use the cookie, here's my two cents...

Are you checking for the cookies to be set in your browser's menu, or in your php script? Because if you're looking for the cookie later in your script, I don't think its available until the next time a page is accessed.

Are you sure MAX_TIME is defined right? If it's mis-defined it could cause the cookie to expire immediately. Try using the numbers instead and see if that helps. Same with $sid. Did you echo out the values of MAX_TIME and $sid to make sure they are set correctly? You never know when a little typo is going to screw up your whole script.

That's all I've got for now. Good luck.
- Walkere
rohan2kool
I'm checking my browser.

Not using sessions, coz i hate them (and i hate them cause i don't understand them). I have made a full library for that reason for authentication and now it's so full fledged, i don't want to switch back to sessions.

yep, MAX_TIME is defined correctly as 86400 (even checked it).
yep, $sid is also defined correctly as a 32-digit hexadecimal number.


[edit]
Wait a minute.. MAX_TIME should be time() + 86400.. so sorry for that.. how could i overlook that... silly me.. thanks a lot for ur reply.. that was what actually made me think.. thanks once again...
Related topics
Do you read comics? What title?
How To : Secure Your PHP Website
phpBB Services
php or js?
PHPBB Cookies
My forum isn't saving cookies
150 frih to make this SIMPLE script
Checking whether a users port is open?
Hey, space.frih.net is now AstroTwister.com. cool, eh?
PHP as site template?
PHP Cookies - Problems
Aliens on 14th of october?
Serve static content from a cookieless domain
Sukhjinder from India
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.