Jump to content

Archived

This topic is now archived and is closed to further replies.

Guest jammyjames

PHP Session

Recommended Posts

Guest jammyjames
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 session
if( !$_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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.