[PHP] How can I detetct if session cookies are enabled?
Hi, I have a site that requires a user to login in for extended function. The site uses sessions. I note that if a user configures his/her browser block all cookies, he/she will not be able to navigate the extended part of the site. Is there a way (PHP code if possible please) to verify if session cookies are enabled in the user's browser? Thanks, Don --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.459 / Virus Database: 258 - Release Date: 2/25/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How can I detetct if session cookies are enabled?
Is there a way (PHP code if possible please) to verify if session cookies are enabled in the user's browser? On the *second* request, check if $_COOKIES['PHPSESSID'] is set. On the initial request, PHP sends the 'PHPSESSID' cookie as part of the response. The browser then returns that cookie in its next request. Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I detetct if session cookies are enabled?
At 17:52 28.02.2003, Don spoke out and said: [snip] I have a site that requires a user to login in for extended function. The site uses sessions. I note that if a user configures his/her browser block all cookies, he/she will not be able to navigate the extended part of the site. Is there a way (PHP code if possible please) to verify if session cookies are enabled in the user's browser? [snip] First of all, if you have URL rewriting enabled (it is by default) any site should be transparently working regardless of the client's cookie settings, as far as sessions are concerned. That said - you can use the SID constant. SID contains either PHPSESSIONID=### if cookies are _DIS_abled, or is empty if cookies are _EN_abled: if (empty(SID)) // ok, go ahead else // issue a warning here Of course this only works after the first response of the client to the site where sessions are enabled. The SID will always contain the session key after starting the session for the very first time, thus the above code will always trigger the warning. -- O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I detetct if session cookies are enabled?
on 01/03/03 3:52 AM, Don ([EMAIL PROTECTED]) wrote: Hi, I have a site that requires a user to login in for extended function. The site uses sessions. I note that if a user configures his/her browser block all cookies, he/she will not be able to navigate the extended part of the site. Is there a way (PHP code if possible please) to verify if session cookies are enabled in the user's browser? On the page that you set the cookie on, you need to append a value like setcookie=true to all the URLs on the page (or perhaps this can be achieved transparently with a header() or meta refresh... Then, on the page following that, if $_GET['setcookie'] is true but you can't find a session id, then you know that the cookie failed. The other way sessions can be passed around is in the URL... you can manually add the SID to all URLs in your site, or recompile PHP with trans-sid, and it will do everything above for you, transparently... if the user has cookies, it will use them, otherwise it will modify URLs to include the SID. Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php