Guest jammyjames Posted June 30, 2006 Share Posted June 30, 2006 Hi,I have a site with a main feature page. People are linking directly to this page and I am not getting visitors on my home page.I wanted to create a session that lasted 24 hours and if expired and the link click it would redirect to the homepage where the session could be started for a further 24 hours.I don't want any messages to appear and I don't want to use a login.Is this possible?I am pretty new to PHP and kind of struggling with this one.Can anyone help?Thanks Link to comment https://forums.phpfreaks.com/topic/13298-php-session/ Share on other sites More sharing options...
sabadell Posted June 30, 2006 Share Posted June 30, 2006 Hi,Although I haven't done this with PHP I believe my experience of ASP will help in terms of the thought process. As such, I think you would need a cookie for this type of activity i.e. a cookie has longer time limits potential than a session and then an if else structure to redirect visitorsif the cookie has expired. I am sure others will offer more script advice though but I hope it will help. Link to comment https://forums.phpfreaks.com/topic/13298-php-session/#findComment-51233 Share on other sites More sharing options...
xyn Posted June 30, 2006 Share Posted June 30, 2006 Yes I do have this on my site for affiliates linking in + out... you can use this in the same way, using a cookie may not work if the users cookies are not switched on and sessions may expire before 24 hours although id use the below code. I used a database though,although if it's non-database it'll be something like...[code=php:0]<?PHP//Check for sessionif( !$_SESSION['hits'] ){//set number$x = "0";$x++;//set session$_SESSION['hits'] = true;//redirect, 3 - seconds; URL=Location.echo '<META HTTP-EQUIV="REFRESH" CONTENT="3;URL=http://www.URL.co.uk/page.htm">';} else {//redirect, 3 - seconds; URL=Location.echo '<META HTTP-EQUIV="REFRESH" CONTENT="3;URL=http://www.URL.co.uk/page.htm">';}?>[/code] Link to comment https://forums.phpfreaks.com/topic/13298-php-session/#findComment-51246 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.