Jump to content

PHP Session

  • Please log in to reply
2 replies to this topic

#1 Guest_jammyjames_*

  • Guests

Posted 30 June 2006 - 01:59 PM


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?


#2 sabadell

  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 30 June 2006 - 02:07 PM

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.

#3 xyn

  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 30 June 2006 - 02:38 PM

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...

//Check for session
if( !$_SESSION['hits'] )
//set number
$x = "0";
//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">';

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users