iwannabeleet Posted January 15, 2008 Share Posted January 15, 2008 Can anyone tell me the best way to check to see if my start_session() cookie was accepted? start_session() always seems to return true and I'd like to modify my scripts behavior depending on whether the cookie was rejected. Thank you all for your help Quote Link to comment https://forums.phpfreaks.com/topic/86209-start_session-if-cookies-disabled/ Share on other sites More sharing options...
trq Posted January 15, 2008 Share Posted January 15, 2008 You could try.... <?php if (isset($_COOKIE['PHPSESSID'])) { // session cookie exists. } ?> Quote Link to comment https://forums.phpfreaks.com/topic/86209-start_session-if-cookies-disabled/#findComment-440305 Share on other sites More sharing options...
iwannabeleet Posted January 15, 2008 Author Share Posted January 15, 2008 thank you, sir! Quote Link to comment https://forums.phpfreaks.com/topic/86209-start_session-if-cookies-disabled/#findComment-440314 Share on other sites More sharing options...
iwannabeleet Posted January 15, 2008 Author Share Posted January 15, 2008 I'm still having a terrible time with this. ISSET seems to return false until the second page load, and I have to know on the initial, first run of the homepage whether the cookie was accepted, but anytime I try to test for it all of the ISSETS return false until the page is reloaded. I know i'm missing something obvious here, can someone noob-slap me in the right direction pls? ??? Quote Link to comment https://forums.phpfreaks.com/topic/86209-start_session-if-cookies-disabled/#findComment-440400 Share on other sites More sharing options...
iwannabeleet Posted January 15, 2008 Author Share Posted January 15, 2008 found this in the manual: Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires. My problem is that I'm using a cookie to mark whether a certain action (which is only to be done once, upon first page load) is done. If the user has cookies disabled, this action will repeat over and over again. Any advice on working around this issue? Quote Link to comment https://forums.phpfreaks.com/topic/86209-start_session-if-cookies-disabled/#findComment-440427 Share on other sites More sharing options...
tibberous Posted January 15, 2008 Share Posted January 15, 2008 The problem is that when PHP sends a cookie, it sends it as a header in the page. There is no way it can know whether the browser will store it or not, so you have to wait and see if you get it back. Quote Link to comment https://forums.phpfreaks.com/topic/86209-start_session-if-cookies-disabled/#findComment-440430 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.