Если все правильно понял то, как то так получается?
Код не авторский, собран из выдачи в гугле + свои додумки.
В JS не силен, подскажите такая конструкция будет работать?
function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
var cookie_string = name + "=" + escape ( value );
if ( exp_y )
{
var expires = new Date ( exp_y, exp_m, exp_d );
cookie_string += "; expires=" + expires.toGMTString();
}
if ( path )
cookie_string += "; path=" + escape ( path );
if ( domain )
cookie_string += "; domain=" + escape ( domain );
if ( secure )
cookie_string += "; secure";
document.cookie = cookie_string;
}
function get_cookie ( cookie_name )
{
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
if ( results )
return ( unescape ( results[2] ) );
else
return null;
}
var s=location.href;
var st = s.substr(s.lastIndexOf("/")+1);
var current_date = new Date();
var cookie_year = current_date.getFullYear ( ) + 1;
var cookie_month = current_date.getMonth ( );
var cookie_day = current_date.getDate ( );
if ( (! get_cookie ( "cookieName" )) && ( st == "index.html") )
{
set_cookie ( "cookieName", "1", cookie_year, cookie_month, cookie_day );
}
if ( ( st == "1.html") ){
set_cookie ( "cookieName", "2", cookie_year, cookie_month, cookie_day );
}
if ( ( st == "2.html") ){
set_cookie ( "cookieName", "3", cookie_year, cookie_month, cookie_day );
}
var check = get_cookie ( "cookieName" );
if ( (check == "1") && !( st == "index.html") ){
top.location = "index.html";
}
if ( (check == "2") && !( st == "1.html") ){
top.location = "1.html";
}
if ( (check == "3") && !( st == "2.html") ){
top.location = "2.html";
}