SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru dragonhawk's Avatar
    Join Date
    Apr 2002
    Location
    Melbourne
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Checking if cookies are enabled before proceeding

    Just wondering if anyone can show me the javascript code to check if cookies are enabled on their browsers such that I could have it redirected to another page if cookies are not enabled?

  2. #2
    SitePoint Wizard davidjmedlock's Avatar
    Join Date
    Dec 2002
    Location
    Nashville, TN USA
    Posts
    1,688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    var expdate = new Date();
    expdate.setTime(expdate.getTime() + (3860*60*1000)) // one hour from now
    document.cookie = "test_cookie=test cookie;expires=" + expdate;
      if (document.cookie)
       return true;
      else
       return false;
    Found that on a JavaScript site a while back, don't remember where though. It works for our readiness test at DigiScript.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •