Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/13298-php-session/
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.
Link to comment
https://forums.phpfreaks.com/topic/13298-php-session/#findComment-51233
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]
Link to comment
https://forums.phpfreaks.com/topic/13298-php-session/#findComment-51246
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.