Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
laravel-adminpanel
Commits
9ffdbb25
Commit
9ffdbb25
authored
Apr 28, 2018
by
Vipul Basapati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Timeout issue resolved #209
parent
53ae2056
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
.env.example
.env.example
+5
-0
SessionTimeout.php
app/Http/Middleware/SessionTimeout.php
+9
-4
No files found.
.env.example
View file @
9ffdbb25
...
...
@@ -21,6 +21,11 @@ CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
#Session Timeout
SESSION_TIMEOUT_STATUS=true
#In Seconds
SESSION_TIMEOUT=600
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
...
...
app/Http/Middleware/SessionTimeout.php
View file @
9ffdbb25
...
...
@@ -3,6 +3,7 @@
namespace
App\Http\Middleware
;
use
Closure
;
use
Cookie
;
use
Illuminate\Session\Store
;
/**
...
...
@@ -39,12 +40,16 @@ class SessionTimeout
*/
public
function
handle
(
$request
,
Closure
$next
)
{
if
(
config
(
'session.timeout_status'
))
{
//Cookie Name for when 'remember me' is checked
$remember_cookie
=
\Auth
::
guard
()
->
getRecallerName
();
if
(
!
Cookie
::
has
(
$remember_cookie
)
&&
config
(
'session.timeout_status'
))
{
$isLoggedIn
=
$request
->
path
()
!=
'/logout'
;
if
(
!
session
(
'lastActivityTime'
))
{
$this
->
session
->
put
(
'lastActivityTime'
,
time
());
}
elseif
(
time
()
-
$this
->
session
->
get
(
'lastActivityTime'
)
>
$this
->
timeout
)
{
}
else
if
(
time
()
-
$this
->
session
->
get
(
'lastActivityTime'
)
>
$this
->
timeout
)
{
$this
->
session
->
forget
(
'lastActivityTime'
);
$cookie
=
cookie
(
'intend'
,
$isLoggedIn
?
url
()
->
current
()
:
'admin/dashboard'
);
$email
=
$request
->
user
()
->
email
;
...
...
@@ -53,7 +58,7 @@ class SessionTimeout
return
redirect
()
->
route
(
'frontend.auth.login'
)
->
withFlashWarning
(
trans
(
'strings.backend.general.timeout'
)
.
$this
->
timeout
/
60
.
trans
(
'strings.backend.general.minutes'
))
->
withInput
(
compact
(
'email'
))
->
withCookie
(
$cookie
);
}
$isLoggedIn
?
$this
->
session
->
put
(
'lastActivityTime'
,
time
())
:
$this
->
session
->
forget
(
'lastActivityTime'
);
$isLoggedIn
?
$this
->
session
->
put
(
'lastActivityTime'
,
time
())
:
$this
->
session
->
forget
(
'lastActivityTime'
);
}
return
$next
(
$request
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment