Find the following line:
Code: Select all
if ($this->customer->isLogged()) {
Code: Select all
if (isset($this->session->data['last']) && (time() - $this->session->data['last'] > 30 * 60)) {
$this->customer->logout();
unset($this->session->data['last']);
$this->response->redirect($this->url->link('account/login', '', true));
}
$this->session->data['last'] = time();
1. It will logout the users at their next activity attempt after 30 minutes
2. It is recommended to use ocmod instead of modifying file directly
3. There is no ajax involvement here therefore it will not redirect automatically
XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart
XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart
I want customers who already logged in to their account to be logged out after 30 minutes of inactivity, if the site is still open or closed.
Thanks
Code: Select all
$this->response->redirect($this->url->link('account/login', 'inactive', true));
otherwise set a message about the 30min inactivity limit on the sign-in page like:
Code: Select all
if (isset($this->request->get['inactive'])) {
sign out message
} else {
limit message
}
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
I am not sure exactly where to put the code you advised.letxobnav wrote: ↑Tue Sep 01, 2020 3:57 pmI would use:so you can check the get variable "inactive" on the sign-in page and set a message that the user was signed-out because of inactivity.Code: Select all
$this->response->redirect($this->url->link('account/login', 'inactive', true));
otherwise set a message about the 30min inactivity limit on the sign-in page like:Code: Select all
if (isset($this->request->get['inactive'])) { sign out message } else { limit message }
you have:
Code: Select all
// Wishlist
if ($this->customer->isLogged()) {
Code: Select all
// automatic sign out after 20 min inactivity
if (isset($this->session->data['last']) && (time() - $this->session->data['last'] > 20 * 60)) {
$this->customer->logout();
unset($this->session->data['last']);
$this->response->redirect($this->url->link('account/login', 'inactive', true));
}
$this->session->data['last'] = time();
just before:
Code: Select all
$this->response->setOutput($this->load->view('account/login', $data));
Code: Select all
if (isset($this->request->get['inactive'])) {
$data['message'] = '<p><i>For your security, you have been Signed Out due to 20 min of inactivity</i></p>';
} else {
$data['message'] = '<p><i>For your security, you will be Signed Out after 20 min of inactivity</i></p>';
}
in file catalog/view/theme/default/template/account/login.twig
you add wherever you want the message to show:
Code: Select all
{{ message }}
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
I tried the code exactly as you said but no luck, I forgot to tell you that I use Journal 3 on OpenCart 3.0.3.2. I added the last code in:
catalog/view/theme/journal/template/account/login.twig
What do you think the problem is
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
just the message does not work?
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
The most important thing for me is to logout customers automatically after 30 min or 60 min of inactivity in the website
again I use OpenCart 3.0.3.2 with Journal 3 Theme, I also use an extention called: Page after login - strict login (cartbinder@gmail.com)
check in your modification directory if there is a catalog/controller/common/header.php and/or catalog/controller/account/login.php in there.
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
Thanks
letxobnav wrote: ↑Tue Sep 01, 2020 5:25 pmin the file catalog/controller/common/header.php
you have:you can add after that:Code: Select all
// Wishlist if ($this->customer->isLogged()) {
in the file catalog/controller/account/login.phpCode: Select all
// automatic sign out after 20 min inactivity if (isset($this->session->data['last']) && (time() - $this->session->data['last'] > 20 * 60)) { $this->customer->logout(); unset($this->session->data['last']); $this->response->redirect($this->url->link('account/login', 'inactive', true)); } $this->session->data['last'] = time();
just before:you can add:Code: Select all
$this->response->setOutput($this->load->view('account/login', $data));
you can later refer those messages to your language files.Code: Select all
if (isset($this->request->get['inactive'])) { $data['message'] = '<p><i>For your security, you have been Signed Out due to 20 min of inactivity</i></p>'; } else { $data['message'] = '<p><i>For your security, you will be Signed Out after 20 min of inactivity</i></p>'; }
in file catalog/view/theme/default/template/account/login.twig
you add wherever you want the message to show:Code: Select all
{{ message }}
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
You handle a check via an event listener and Ajax .
FWIW - The header shouldn't really be responsible for handling this type of logic.
Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
+ 1
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
With jQuery, this can be done. Look it up on Google.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: No registered users and 78 guests