Re: Cookies detect and $_SESSION
| From: | Jim Dam | Date: | Mon, 05 Aug 2002 22:06:48 +0000 |
| Subject: | Re: Cookies detect and $_SESSION | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-111266@lists.php.net to get a copy of this message | ||
if (isset($_SESSION['cookie'])) {
print error_message;
}
----- Original Message -----
From: "Andre Dubuc" <aajdubuc@webhart.net>
To: <php-general@lists.php.net>
Sent: Monday, August 05, 2002 5:09 PM
Subject: [PHP] Cookies detect and $_SESSION
> 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
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>