Make 'em eat cookies!

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
heyrad
Forum Newbie
Posts: 1
Joined: Mon Jun 16, 2003 4:02 pm
Location: new york
Contact:

Make 'em eat cookies!

Post 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
User avatar
trollll
Forum Contributor
Posts: 181
Joined: Tue Jun 10, 2003 11:56 pm
Location: Round Rock, TX
Contact:

Javascript holds the key.

Post 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! :)
Post Reply