Re: how to detect if the client's browser accepts cookies ?

From: Date: Fri, 31 May 2002 09:58:18 +0000
Subject: Re: how to detect if the client's browser accepts cookies ?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-100068@lists.php.net to get a copy of this message
On Friday 31 May 2002 10:53 am, David Eisenhart wrote: > Hi > > I am writing a function to construct page links within my site; I want it > to append the session id to the URL's query string if the client does not > accept cookies (and ignore the session id if the client does accept > cookies). > > How do I detect if the client browser accepts cookies? > Indeed, has anyone got such a function as described above? Here's one approach you could try. Set a cookie, send a redirect, and see if you get the cookie back ... Script 1 - cookiecheck1.php <?php setcookie("testcookie","ok"); header("Location: cookiecheck2.php"); ?> Script 2 - cookiecheck2.php <?php if ($testcookie =="ok") print "This browser appears to handle cookies OK."; else print "This browser either doesn't support use of cookies, or has cookie use disabled."; ?> Regards - Nick

« previous php.general (#100068) next »