Hello,

I've read all about how to expire a session, but this doesn't seem to be what I need. (unless I misunderstood it) The way I understand sessions, it's all about expiring the _cache_. Here's what I want:

I want to allow my site visitors to search without logging in.

However, once they have a search results page, I don't want them to be able to leave it for days, and then come back and click on one of the links. (and have that old data sent to the server for processing)

Instead, as soon as they click _anywhere_ on an old page, I want a dialog box telling them it's expired to come up, and I want the page to erase itself.

But.....maybe I don't have to worry about this at all? Once I load my site onto a web host's server, perhaps it will do this automatically? I'm currently developing my site locally using a local Apache server.

If you got a good laugh out of this question, could you explain the joke to me?? I'm brand new to php, so please don't answer in acronyms! :-)

Thank you!

A Session generally expires when the browser is closed. Just set the Session variable on the page that you want the user to access the search result through. Then on the search result page have a simple script like:

session_start();
if(!$_SESSION['loggedin']="valid")
{
header ('Location:login.php');
}

Notice the !(not sign). This will tell the server that if they are not logged in, to redirect them to the page (I used login.php) that you want them to go to.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.