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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if cookies are enabled?

Status
Not open for further replies.

AcidReignX

Programmer
Feb 28, 2005
32
US
I'm having a few people come to my site that have cookies disabled. Whenever they log in it will say "You have successfully logged in", but then they can't do anything because they're not really logged in... I know the problem is due to not having cookies enabled, but how do I actually check to confirm if they have it enabled?

I'm saving the login information as a session variable (not sure how secure that is... also would like to know that).
 
Cookie-based sessions are the most secure way to maintain state information in PHP. This assumes that you have register_globals set to "off".

The only way to check whether you can set a cookie is to try to set one. If you get the cookie back, cookies are enabled.

If your authentication code is sending out false positives, there is likely something wrong with your scripts' logic. If a login ID of some kind is stored in a session, when cookies are not available there should be no login ID in the session.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Holy crap I'm retarded... Checking the variable itself didn't even cross my mind. Sorry for the waste of computer bits.

At any rate, thanks for the information about the session handling. That's definitely good to know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top