Jump to content

[SOLVED] !!PHP GURUS NEED UR HELP!! Session expire redirect to relogin


kazsil

Recommended Posts

Hello All!

  I have been looking every where for a fairly simple script. And I am ready to pull my hair out!  ???

I am not new to PHP but I am still needing to learn a lot.

 

This is all I want to do...

After a user has logged in a session starts (works fine).  They go into a member’s only areas (works fine).  But what I want to happen is if there is inactivity for 15 minutes, I want it to have a  pop up warning them and then redirect them to the login page. 

 

I just don’t get how to do this and it seems like there are a thousand different ways to do a little bit of each part of the problem, and I am confused on how to do this!

 

I truly appreciate any help you can give me!!!

Thanks SO much! :-*

Jenn

 

Link to comment
Share on other sites

Here is what I was able to throw together... And I am not sure if I am barking up the right tree or trying to put a round peg in a square hole....

 

Here is what I have so far... (and it doesn’t do the popup window)...

 

<?php session_cache_expire(1);
$cache_expire = session_cache_expire();
/* set the cache limiter to 'private' */
session_cache_limiter('private');
$cache_limiter = session_cache_limiter();


session_start();
  header("cache-control: private");

if(!isset($_SESSION['Party_ID'])){
    $msg = "Your session has expired.  Please log back in.";
    header("Location: login.php?msg=".$msg);
} 
?>

 

when i run this code... nothing happens.  it just sits and stares at me like I dont have a one minute timeout on this page.

 

So the theory would be  after 1 minute (for testing time 15 for production) it would somehow kill the session and send them to the login page.  But I wait... and it doesn’t redirect.

 

Maybe I just dont know what is going on with this code or if I have something wrong, but what I want it to do is...

1. After 15 minutes of inactivity warn the user that  their session has expired with maybe a popup (like rarebit suggested, thank you.)

2.  kill the session so if they hit the back button, they cant bring their session back.

3.  redirect them to login.php

 

That is what I would like to happen... but right now of it works.

 

Any thoughts would be greatly appreciated!

Thnaks!

Jen

 

Link to comment
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.