The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Homepage with Cookies

2 posters

Go down

Homepage with Cookies Empty Homepage with Cookies

Post by Jut0z Wed 16 Jun - 1:16

Hey, I was wondering if it's possible with phpBB2 to make a Homepage, that if you've never visited that takes you to a Terms of Service page, which you have to accept before you can enter the website, then upon your next visit cookies that are enabled will tell the site you've accepted and it re-routes you to the normal homepage instead of the terms of service.
avatar
Jut0z
New Member

Posts : 8
Reputation : 0
Language : English

Back to top Go down

Homepage with Cookies Empty Re: Homepage with Cookies

Post by rblatch Wed 16 Jun - 1:22

Code:

<script>
 
// page to go to if cookie exists
go_to = "RE-DIRECTION URL";

// number of days cookie lives for
num_days = 60;
function ged(noDays){
    var today = new Date();
    var expr = new Date(today.getTime() + noDays*24*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;
    }
}

readCookie("seenit");
// -->
</script>

Paste this at the top of the HTML page of you TOS Smile
rblatch
rblatch
Active Poster

Male Posts : 1042
Reputation : 2
Language : HTML &amp;amp; CSS (Learning)
Location : Graphics Central

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum