PHP REDIRECT COOKIE HELP!!!
Posted: Tue Feb 24, 2009 6:58 pm
Hi There! So I have a PHP CMS website and I have a splash.html page that need to be show up only once per session. So I found this script:
BUT I can not make it work per session only. (So cookie will expire after each time when you close your browser.) I get confused on Date/Time part.
Can somebody help me with it? Please...
Code: Select all
<script type="text/javascript">
<!--
function redirect()
{
var thecookie = readCookie('doRedirect');
if(!thecookie)
{
window.location = 'splash/splash.html';
}
}
function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
window.onload = function()
{
redirect();
createCookie('doRedirect','true','999');
}
//-->
</script>Can somebody help me with it? Please...