/    Sign up×
Community /Pin to ProfileBookmark

Alert User 5 minutes remain and FORCE them to logout.

I have a table of datetime fields. We already have a max 20 minute limit to be logged in before it kicks you out of the system. We use the following code for that:

[code=php]session_cache_expire( 20 );
session_start(); // NEVER FORGET TO START THE <strong class=”highlight”>SESSION</strong>!!!
$inactive = 1200;
if(isset($_SESSION[‘start’]) ) {
$session_life = time() – $_SESSION[‘start’];
if($session_life > $inactive){
header(“Location: ../logout.php”);
}
}
$_SESSION[‘start’] = time();[/code]

But When they log in, I store the next batch processing date and time from that datetime table into a SESSION variable called $_SESSION[‘procdate’].

I want to see if the time remaining UNTIL $_SESSION[‘procdate’] is less than our default 20 minutes. If so, then force them to log out when they reach the $_SESSION[‘procdate’] time.

$_SESSION[‘procdate’] is a UNIXTIMESTAMP.

If its possible, I’d like to display an alert or popup or activate a JQuery popup when there is 5 minutes remaining.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @swg1cor14 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...