View Full Version : redirect from index page
i.edwards384429
02-16-2010, 06:45 AM
Hi
I'm trying to setup a redirect based on a 5 day cookie life. I've searched and cannot find a solution recipe
so over the past weeks I've been working on it.
I now have on my index.php page above the header
<?php
if( !(isset($_COOKIE["splashCookie"])) ) {
header("Location: http://www.ashburyblinds.co.uk/splash.php");
}
?>
on the page splash.php I have
<?php
if ("" == "") {
setcookie("splashCookie", "visited", time()+(60*60*24*5), "/", "", 0);
}
?>
This does not seem to work, any ideas why?
thanks
Ian
Dani Chankhour
02-16-2010, 01:24 PM
On your splash page, you need to change:
if ("" == "") { to
if( !(isset($_COOKIE["splashCookie"])) ) {
because you only want to set the cookie once, otherwise the cookie expiration time will be incremented by 5 days every time your visit the page.
i.edwards384429
02-17-2010, 03:04 AM
Hi Dani
regrettably no further forward!
If I go to
http://www.ashburycurtains.co.uk/index.php
the page does redirect to
http://www.ashburycurtains.co.uk/splash.php
the code at the top of the index page is:
<?php
if( !(isset($_COOKIE["splashCookie"])) ) {
header("Location: http://www.ashburycurtains.co.uk/splash.php");
}
?>
I can find no other code relating to the cookie ie no onLoad events.
On the splash page is the code:
<?php
if( !(isset($_COOKIE["splashCookie"])) ) {
header("Location: http://www.ashburycurtains.co.uk/splash.php");
}
?>
Again there appears to be no onload event set or any other code.
The help files are not "helpful" (to me a novice) and there is regretably no road map for what I assume is a core use of cookies!
would appreciate your input
thanks
Ian
Dani Chankhour
02-18-2010, 10:36 PM
When i go to:
http://www.ashburycurtains.co.uk/index.php
the first time I'm redirected to:
http://www.ashburycurtains.co.uk/splash.php
which is correct. And when i go back to your index page, i'm not redirected anymore, which also seems correct. Could you explain a little more about what is not working?
i.edwards384429
02-19-2010, 01:30 AM
Hi Dani
apologies late late last night ( 1 am - dammed olympics) I noticed a possible code error which got it all working.
Became involved in the Olympics and forgot to post the solution.
As always simple- I forgot that splashCookie is different from splashcookie
changed the case and all is now working!!!
thanks
Ian
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.