0

Hello friends,

Am having a membership website and i need some help. How do i code any login required (member's) page to automatically (log out) request relogin after 5 minutes of idleness of the page? and how do i redirect the member back to page where he was loged out after signing in?

Regards

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by genevish
0

I'll assume you are using sessions to track your login across pages. Set a session variable called "LastAction" as a timestamp. If the user visits a page, check to see if the LastAction timestamp is less than 5 minutes ago. If so, update it to the current timestamp. If not, log them out and display the login form.

As for the second part of the question, I prefer not creating a "login" page at all. Instead, display the login form on any page that requires a login if the user is not already logged in. When they log in, the login form just redirects to the current page. Peudo-code for an exaple page would be:

Page: myAccount.php

if login form was submitted
    Check login credentials
   If valid, add session variables
if login session doesn't exist OR if session has expired
     Display login form.  On submit, redirect to current page
else
    Display page

Edited by genevish: Added code tags for better readability

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.