Persistent Cookies for login

Issues related to forms.
Post Reply
User avatar
ruel.lago22
 
 
Posts: 59
Joined: Thu Feb 01, 2018 11:32 am

Persistent Cookies for login

Post by ruel.lago22 »

Hello everyone,

Just want to ask if anybody has tried using a persistent cookies for our login in WWB? I tried to convert my existing website made with WWB of course, into a mobile app for iOS and Android. It seems to work and everything is fine and goes the way I want it to be. But I am having an issue about the signed in users? They keeps from logging out when the browser/app is closed. I was advised to change the cookie to persistent (none expiring/permanent) cookie to prevent users from being logged out. Hope someone can share their script/code used on their WWB :) Thank you in advance! God bless you all!
User avatar
Pablo
 
Posts: 22429
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Persistent Cookies for login

Post by Pablo »

You can set the (sessions) timeout for cookies in the properties of the login object.
A session timeout is implemented on the server (PHP), so it does not matter which browser is used.
User avatar
ruel.lago22
 
 
Posts: 59
Joined: Thu Feb 01, 2018 11:32 am

Re: Persistent Cookies for login

Post by ruel.lago22 »

Pablo wrote: Wed Sep 26, 2018 5:58 am You can set the (sessions) timeout for cookies in the of the login object.
I see, what values should I set there to set the cookies expiry to persistent/permanent cookies? Or if it's not possible, what values should I put there to make it last forever or the longest the cookies can stay? Thank you Pablo 😄
User avatar
Pablo
 
Posts: 22429
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Persistent Cookies for login

Post by Pablo »

Note that this is not specific to the login tools.

See 'expires':
http://php.net/manual/en/function.setcookie.php
User avatar
ruel.lago22
 
 
Posts: 59
Joined: Thu Feb 01, 2018 11:32 am

Re: Persistent Cookies for login

Post by ruel.lago22 »

Thank you Pablo 😄 I will look into it.
User avatar
ruel.lago22
 
 
Posts: 59
Joined: Thu Feb 01, 2018 11:32 am

Re: Persistent Cookies for login

Post by ruel.lago22 »

***UPDATE***

It worked :lol: If anyone needs persistent cookies that will last 10 years from now. Use the code below :) Don't forget to convert the login tools to Form first to edit the source code! Thank you again Pablo!

Code: Select all

      if ($rememberme)
      {
         setcookie('username', $_POST['username'], time()+10*365*24*60*60);
         setcookie('password', $_POST['password'], time()+10*365*24*60*60);
      }
User avatar
ruel.lago22
 
 
Posts: 59
Joined: Thu Feb 01, 2018 11:32 am

Re: Persistent Cookies for login

Post by ruel.lago22 »

***UPDATE***

Hello everyone,

I know this is no longer scope of support of Pablo, if anyone can help me with this. For sure I will not be the only one who needs this feature in the future.

I tried the code above and it worked for a little while. When I close my browser and after a few minutes, the cookies expires. I double checked it thru the browser cookies, and it's set to expire for my website after 10 years. I'm not sure why am I still being logged off. I don't clean cache and history data on my browsers. Even tried it using Google Chrome for Android and it's the same thing.

Website: https://washub.ph
Username: 090909
Password: demo

Note: Remember me box is checked and it's default on my website. Please do not proceed to checkout. Website is live. Thank you in advance!
User avatar
ruel.lago22
 
 
Posts: 59
Joined: Thu Feb 01, 2018 11:32 am

Re: Persistent Cookies for login

Post by ruel.lago22 »

Up.
Post Reply