How to set Different Auto logout time for each user in Laravel
up vote
2
down vote
favorite
I have a time in mins for each one user in his profile, the user should automatically be logged out after that time.
Example:
User 1: Auto logout time => 60 Mins
User 2: Auto logout time => 120 Mins
User 3: Auto logout time => 150 Mins
So after login, user 1 should log out after 60 mins of login, user 2 after 120 mins and user 3 after 150 mins. Does anyone have any idea that how to achieve this?
I am thinking to change the session lifetime from the session.php file for every login request, but don't know it will work or Not.
Thanks in Advance.
javascript jquery laravel laravel-5 laravel-5.2
add a comment |
up vote
2
down vote
favorite
I have a time in mins for each one user in his profile, the user should automatically be logged out after that time.
Example:
User 1: Auto logout time => 60 Mins
User 2: Auto logout time => 120 Mins
User 3: Auto logout time => 150 Mins
So after login, user 1 should log out after 60 mins of login, user 2 after 120 mins and user 3 after 150 mins. Does anyone have any idea that how to achieve this?
I am thinking to change the session lifetime from the session.php file for every login request, but don't know it will work or Not.
Thanks in Advance.
javascript jquery laravel laravel-5 laravel-5.2
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have a time in mins for each one user in his profile, the user should automatically be logged out after that time.
Example:
User 1: Auto logout time => 60 Mins
User 2: Auto logout time => 120 Mins
User 3: Auto logout time => 150 Mins
So after login, user 1 should log out after 60 mins of login, user 2 after 120 mins and user 3 after 150 mins. Does anyone have any idea that how to achieve this?
I am thinking to change the session lifetime from the session.php file for every login request, but don't know it will work or Not.
Thanks in Advance.
javascript jquery laravel laravel-5 laravel-5.2
I have a time in mins for each one user in his profile, the user should automatically be logged out after that time.
Example:
User 1: Auto logout time => 60 Mins
User 2: Auto logout time => 120 Mins
User 3: Auto logout time => 150 Mins
So after login, user 1 should log out after 60 mins of login, user 2 after 120 mins and user 3 after 150 mins. Does anyone have any idea that how to achieve this?
I am thinking to change the session lifetime from the session.php file for every login request, but don't know it will work or Not.
Thanks in Advance.
javascript jquery laravel laravel-5 laravel-5.2
javascript jquery laravel laravel-5 laravel-5.2
asked 9 hours ago
Amol Rokade
7619
7619
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
For this you can use setInterval
javascript function
var timeoutSeconds = <?php echo Session::get('timeoutSeconds'); ?>
var _idleSecondsCounter = 0;
window.setInterval(CheckIdleTime, timeoutSeconds);
function CheckIdleTime() {
_idleSecondsCounter++;
var oPanel = document.getElementById("SecondsUntilExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
document.getElementById('logout-form').submit();
}
}
In login controller you can set session like this
$userCount = 1;
$timeOutSeconds = 60 * $userCount;
Session::put('timeoutSeconds', $timeOutSeconds);
For Server Side
Create a Background Job in Laravel and do a delayed dispatch after login method.
Delayed Job Dispatch
3
A client side solution isn't very secure for this.
– Rory McCrossan
8 hours ago
Yes I agree with @RoryMcCrossan. If you need this in server side then I think need to add a scheduler to check whether the current user having valid session or not. If not logout
– sanu
8 hours ago
Yes @RoryMcCrossan, I agree with you it's not secure, Isn't there another way to do this?
– Amol Rokade
8 hours ago
I don't know enough about PHP/Laravel to give you a solution, but that is definitely where you need to be looking
– Rory McCrossan
8 hours ago
Ok. Thanks, Appreciate your help.
– Amol Rokade
8 hours ago
|
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
For this you can use setInterval
javascript function
var timeoutSeconds = <?php echo Session::get('timeoutSeconds'); ?>
var _idleSecondsCounter = 0;
window.setInterval(CheckIdleTime, timeoutSeconds);
function CheckIdleTime() {
_idleSecondsCounter++;
var oPanel = document.getElementById("SecondsUntilExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
document.getElementById('logout-form').submit();
}
}
In login controller you can set session like this
$userCount = 1;
$timeOutSeconds = 60 * $userCount;
Session::put('timeoutSeconds', $timeOutSeconds);
For Server Side
Create a Background Job in Laravel and do a delayed dispatch after login method.
Delayed Job Dispatch
3
A client side solution isn't very secure for this.
– Rory McCrossan
8 hours ago
Yes I agree with @RoryMcCrossan. If you need this in server side then I think need to add a scheduler to check whether the current user having valid session or not. If not logout
– sanu
8 hours ago
Yes @RoryMcCrossan, I agree with you it's not secure, Isn't there another way to do this?
– Amol Rokade
8 hours ago
I don't know enough about PHP/Laravel to give you a solution, but that is definitely where you need to be looking
– Rory McCrossan
8 hours ago
Ok. Thanks, Appreciate your help.
– Amol Rokade
8 hours ago
|
show 2 more comments
up vote
2
down vote
For this you can use setInterval
javascript function
var timeoutSeconds = <?php echo Session::get('timeoutSeconds'); ?>
var _idleSecondsCounter = 0;
window.setInterval(CheckIdleTime, timeoutSeconds);
function CheckIdleTime() {
_idleSecondsCounter++;
var oPanel = document.getElementById("SecondsUntilExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
document.getElementById('logout-form').submit();
}
}
In login controller you can set session like this
$userCount = 1;
$timeOutSeconds = 60 * $userCount;
Session::put('timeoutSeconds', $timeOutSeconds);
For Server Side
Create a Background Job in Laravel and do a delayed dispatch after login method.
Delayed Job Dispatch
3
A client side solution isn't very secure for this.
– Rory McCrossan
8 hours ago
Yes I agree with @RoryMcCrossan. If you need this in server side then I think need to add a scheduler to check whether the current user having valid session or not. If not logout
– sanu
8 hours ago
Yes @RoryMcCrossan, I agree with you it's not secure, Isn't there another way to do this?
– Amol Rokade
8 hours ago
I don't know enough about PHP/Laravel to give you a solution, but that is definitely where you need to be looking
– Rory McCrossan
8 hours ago
Ok. Thanks, Appreciate your help.
– Amol Rokade
8 hours ago
|
show 2 more comments
up vote
2
down vote
up vote
2
down vote
For this you can use setInterval
javascript function
var timeoutSeconds = <?php echo Session::get('timeoutSeconds'); ?>
var _idleSecondsCounter = 0;
window.setInterval(CheckIdleTime, timeoutSeconds);
function CheckIdleTime() {
_idleSecondsCounter++;
var oPanel = document.getElementById("SecondsUntilExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
document.getElementById('logout-form').submit();
}
}
In login controller you can set session like this
$userCount = 1;
$timeOutSeconds = 60 * $userCount;
Session::put('timeoutSeconds', $timeOutSeconds);
For Server Side
Create a Background Job in Laravel and do a delayed dispatch after login method.
Delayed Job Dispatch
For this you can use setInterval
javascript function
var timeoutSeconds = <?php echo Session::get('timeoutSeconds'); ?>
var _idleSecondsCounter = 0;
window.setInterval(CheckIdleTime, timeoutSeconds);
function CheckIdleTime() {
_idleSecondsCounter++;
var oPanel = document.getElementById("SecondsUntilExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
document.getElementById('logout-form').submit();
}
}
In login controller you can set session like this
$userCount = 1;
$timeOutSeconds = 60 * $userCount;
Session::put('timeoutSeconds', $timeOutSeconds);
For Server Side
Create a Background Job in Laravel and do a delayed dispatch after login method.
Delayed Job Dispatch
edited 8 hours ago
answered 9 hours ago
sanu
179111
179111
3
A client side solution isn't very secure for this.
– Rory McCrossan
8 hours ago
Yes I agree with @RoryMcCrossan. If you need this in server side then I think need to add a scheduler to check whether the current user having valid session or not. If not logout
– sanu
8 hours ago
Yes @RoryMcCrossan, I agree with you it's not secure, Isn't there another way to do this?
– Amol Rokade
8 hours ago
I don't know enough about PHP/Laravel to give you a solution, but that is definitely where you need to be looking
– Rory McCrossan
8 hours ago
Ok. Thanks, Appreciate your help.
– Amol Rokade
8 hours ago
|
show 2 more comments
3
A client side solution isn't very secure for this.
– Rory McCrossan
8 hours ago
Yes I agree with @RoryMcCrossan. If you need this in server side then I think need to add a scheduler to check whether the current user having valid session or not. If not logout
– sanu
8 hours ago
Yes @RoryMcCrossan, I agree with you it's not secure, Isn't there another way to do this?
– Amol Rokade
8 hours ago
I don't know enough about PHP/Laravel to give you a solution, but that is definitely where you need to be looking
– Rory McCrossan
8 hours ago
Ok. Thanks, Appreciate your help.
– Amol Rokade
8 hours ago
3
3
A client side solution isn't very secure for this.
– Rory McCrossan
8 hours ago
A client side solution isn't very secure for this.
– Rory McCrossan
8 hours ago
Yes I agree with @RoryMcCrossan. If you need this in server side then I think need to add a scheduler to check whether the current user having valid session or not. If not logout
– sanu
8 hours ago
Yes I agree with @RoryMcCrossan. If you need this in server side then I think need to add a scheduler to check whether the current user having valid session or not. If not logout
– sanu
8 hours ago
Yes @RoryMcCrossan, I agree with you it's not secure, Isn't there another way to do this?
– Amol Rokade
8 hours ago
Yes @RoryMcCrossan, I agree with you it's not secure, Isn't there another way to do this?
– Amol Rokade
8 hours ago
I don't know enough about PHP/Laravel to give you a solution, but that is definitely where you need to be looking
– Rory McCrossan
8 hours ago
I don't know enough about PHP/Laravel to give you a solution, but that is definitely where you need to be looking
– Rory McCrossan
8 hours ago
Ok. Thanks, Appreciate your help.
– Amol Rokade
8 hours ago
Ok. Thanks, Appreciate your help.
– Amol Rokade
8 hours ago
|
show 2 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371781%2fhow-to-set-different-auto-logout-time-for-each-user-in-laravel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown