Hi, I want to implement a typical login with the typical checkbox "Remember my password" that when checked, tu session should be persistent after close navigator and reopen again (if not, the session must be destroyed including after X secons of inactivity). The question is, how to make this (I thing I must use cookies for this purpose instead of session, but the way of work with cookies in laravel seems more complex than sessions).
By the other way, what is the way to detect a expired session and set it of X minutes of inactivity?
[Semi-solution] Hi, I'm on discord chat, and thre's a laravel group very active. They told me to use the config() function to set session parameters as follow:
if ($request->has('remember')) {
// Use infinite session
config('session.lifetime', 1000000);
config('session.expire_on_close', false);
} else {
config('session.lifetime', 120);
config('session.expire_on_close', true);
}
The problem is that it doesn't works, the session is always closed when I close navigator.
The request will only work as it is loaded. It is one-time thing that does not live more then one browser reload.
Your code works but it probably only uses the else section. Try to put dd('im here') and see what you are really using. It should in theory work on a second request but testing testing and testing is the key here.
@Snapey the problema is that I can't use it, my DB is customized and I can't user laravel default tables for use the auth module. The only thing I want is to implement using session() object, a basic login with the option to set the checkbox "Remember my password". This was dune in native php code using $_COOKIES instead of $_SESSION, but I'd like to use laravel better instead native php (if can be possible)
my DB is customized and I can't user laravel default tables for use the auth module.
That's ok though? You can tell laravel which table to use for auth if it isn't "users" (look at config/auth.php), as well as define the "name" field to use (uses email by default) and the name of the password field to use. It's highly customizable. Just override the trait methods in your login controller, etc.
@Cronix I don't understand how works the Auth module, but yes the session object, that's the problem. I can't use Auth simply because my users table is costumized for an Android application, it's simply impossible to use Auth in my laravel project. I have to use sessions or cookies instead of.