Skip to content

Instantly share code, notes, and snippets.

@chartrandf
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chartrandf/405048daac5e02c5672c to your computer and use it in GitHub Desktop.
Save chartrandf/405048daac5e02c5672c to your computer and use it in GitHub Desktop.
Snippet - Users timeout in Laravel
<?php
// If the user isn't logged in, don't do anything, just return
if(!Auth::user()) {
return false;
}
$now = new DateTime();
$last_activity = Auth::user()->last_activity;
$diff = ( date diff magic )
// Or whatever value in whatever format is needed... like I said, pseudo code
$timeout = "40";
if($diff > $timeout) {
Auth::logout();
return Redirect::to('login')->with('timeout','Session timed out, please login again.');
}
// TImeout has not occurred, update last_activity
Auth::user()->last_activity = $now;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment