Cookies detect and $_SESSION

From: Date: Mon, 05 Aug 2002 21:09:24 +0000
Subject: Cookies detect and $_SESSION
Groups: php.general 
Request: Send a blank email to php-general+get-111260@lists.php.net to get a copy of this message
I'm trying to detect whether the user has cookies enabled on my opening page. Only as I neared the end of coding, have I discovered that my site is totally dependent upon cookies since $_SESSION['whatever_has_been_set] uses cookies! So far, I've tried setting <?php $_SESSION['cookie'] = "yes"; session_write_close(); ?> in the first lines before the headers are set (with <?php session_start(); ob_start(); ?>). Later in the code, I've tried to pick up the empty Array that $_SESSION produces if the user has cookies disabled: <?php if ($_SESSION['cookie'] == "yes") { } else { print ("<h2>Cookies must be enabled to use this site</h2>"); } ?> I've also tried (instead of 'else') elseif ($_SESSION['cookie'] == "") { print ("<h2>Cookies must be enabled to use this site</h2>"); } and elseif (is_null($_SESSION['cookie'] ) { print ("<h2>Cookies must be enabled to use this site</h2>"); } These do not work. Any ideas where I'm going wrong? Any help greatly appreciated. Regards, Andre

« previous php.general (#111260) next »