How to redirect user if they have a cookie javascript

后端 未结 2 1378
醉话见心
醉话见心 2021-01-29 16:33

I need to know how to give the user a cookie when they visit the page for the first time in javascript. Then i need the cookie to expire in 1 hour and it to redirect them if the

相关标签:
2条回答
  • 2021-01-29 16:51

    A related solution is described in redirecting to a splash page.

    0 讨论(0)
  • 2021-01-29 17:04

    if it is ok to use Jquery you can use the Jquery plugin

    Set a cookie

    $.cookie("example", "foo", { path: '/', expires: 7 });
    

    Get a cookie

    alert( $.cookie("example") );
    

    Delete the cookie

    $.cookie("example", null);
    

    Using this you write your custom logic for redirection in javascript

    0 讨论(0)
提交回复
热议问题