Page 1 of 1

Make 'em eat cookies!

Posted: Mon Jun 16, 2003 4:02 pm
by heyrad
Hi all,

I want my users to HAVE to rely on cookies for my sessions. It's not too much to ask and it gives me a warm fuzzy feeling to know that my data is a bit safer.. Anyway, I could use a little help with what might be a very simple dilema. I want to check that a user has cookies enabled and if not, be able to notify them that they must. I could use a redirect trick after setting a cookie and then looking for that cookie on the next page, but that seems so amateurish. Maybe a little javascript or something a bit more elegant would do the trick.

thanks for the help.

-heyrad

Javascript holds the key.

Posted: Mon Jun 16, 2003 5:24 pm
by trollll
A simple javascript can detect it (I think) across the board for browsers and platforms.

Code: Select all

<script type="text/javascript">
if (document.cookie) &#123;
    document.location.replace("realsite.php");
&#125; else &#123;
    document.write("If you don't accept cookies, you don't use this site.");
&#125;
</script>
Hope that help! :)