{"id":761,"date":"2008-05-13T05:45:56","date_gmt":"2008-05-13T12:45:56","guid":{"rendered":"http:\/\/css-tricks.com\/?p=761"},"modified":"2013-11-08T06:15:45","modified_gmt":"2013-11-08T13:15:45","slug":"redirecting-to-a-splash-page-but-only-once-with-cookies","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/redirecting-to-a-splash-page-but-only-once-with-cookies\/","title":{"rendered":"Redirecting to a Splash Page ( …but only once! ) with Cookies"},"content":{"rendered":"
<\/p>\n
Splash pages can be annoying. You know the ones… like being forced to watch some advertisement before you can see the page you are trying to get to. Or maybe some fancy introduction to a site that you are automatically redirected to every time you visit. Great.<\/p>\n
There are some circumstances where a splash page can be useful. Say you are running a band website and they release a new album. You may want to redirect people visiting to a splash page introducing the new album. This might even be welcome by the bands fans, who would want to know about it and have the opportunity to buy it. But, they certainly wouldn’t welcome it the 5th time they went to the site and were re-directed.<\/p>\n
Let’s fix that!<\/p>\n
<\/p>\n
First let’s get the desired functionality straight:<\/p>\n
Has the user been to this site before?<\/strong> If NO is the answer, we need to make sure that the next time this question is asked the answer is YES. And how do we achieve this magical web intelligence? With the internet’s most delicious functionality: the cookie!<\/p>\n
\nYES<\/em>: Go to regular homepage
\nNO<\/em>: Redirect to splash page<\/p>\nSetting and Getting the Cookie<\/h3>\n