Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2010
    Posts
    127
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Adjusting Cookie

    Hey all,

    I have set up a cookie that redirects the visitor if they have visited the page before. However, I'd like to make some adjustments to it to where if they have cookies turned off, it automatically redirects them to a page that requests them to turn on cookies. Any ideas?

    Code:
    <script>
    num_days = 24;
    function ged(noDays){
        var today = new Date();
        var expr = new Date(today.getTime() + noDays*60*60*1000);
        return  expr.toGMTString();
    }
    
    function readCookie(cookieName){
        var start = document.cookie.indexOf(cookieName);
        if (start == -1){ 
            document.cookie = "seenit=yes; expires=" + ged(num_days);
        } else {
            window.location = go_to;
        }
    }
    
    var go_to = "/index.php?module=article&id=310";
    
    readCookie("seenit");
    </script>

  • #2
    Regular Coder
    Join Date
    Oct 2010
    Posts
    127
    Thanks
    26
    Thanked 0 Times in 0 Posts
    nevermind. I figured it out. Looks like I'm finally starting to understand js


  •  

    Posting Permissions

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