Re: How to detect if cookies are enable?

From: Date: Tue, 20 Nov 2001 21:40:48 +0000
Subject: Re: How to detect if cookies are enable?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75292@lists.php.net to get a copy of this message
Pekesan wrote: > > Does anyone know how to detect if the client browser allows cookies or not? > > Thanks in advance......... Here's one way to do that (This is from 'Professional PHP Programming' published by Wrox Press): Step 1: - send a set-cookie request - reload current page Step 2: - check whether set-cookie request was successful <code> if (empty($check)) { $page = "$PHP_SELF?check=1"; header("Location: $page"); setcookie("testcookie", "1"); } else { if (empty($testcookie)) { echo "Could not set test cookie. You browser has disabled cookies support."; } else { echo "Your browser supports cookies } } </code> Hope that helps. ;) -- Dmitri Zakharov email: zakd@max-t.com phone: (514)938-7389

« previous php.general (#75292) next »