I have a site at mysite.com/index.html and replicated site at mysite.com/test.html.
I need to set cookie for visitor who visited mysite.com/test.html , so if he types in browser mysite.com ,he will be redirected to mysite.com/test.html for next 30 days.
I'm using jquery.cookie.js plugin
I have placed in mysite.com/test.html following code:
$.cookie('test', 'test', { expires: 30, path: '/' })
And on mysite.com/index.html
$(function() {
if ($.cookie('test')) window.location.href = 'http://www.mysite.com/test.html';
});
I'm very new to js and jquery,so please tell me if it's a correct way to set cookie,read and redirect.
Thank you.