Is this possible to keep login credentials alive using PHP?

You can increase session timeout using PHP. If you want your session to stay alive until the browser is closed you can simply set session.gc_maxlifetime to 0:

ini_set('session.gc_maxlifetime', 0);

If you want infinite session you can set session.gc_maxlifetime to:

 ini_set('session.gc_maxlifetime', 60 * 60 * 24 * 365); # session expires after 1 year

Otherwise you can set session.gc_probability to 0 before starting the session. This will give the garbage collector a 0% chance of removing session data. You have to do this in all applications that share the same session storage location.

 ini_set('session.gc_probability', 0);

You can also change these values from the php.ini file

If u need more information about php.ini variables check the php documentation: https://www.php.net/manual/en/session.configuration.php#ini.session.gc-probability


You can use php $_SESSION or COOKIE for this

$_SESSION['USER'] = ['current user details']; 

You can combine both cookie and session for great experiance as a beginer use seasion first

You cant set expiry date of cookie morethan 2038 or it will wrap up


This is called OAauth Authentication. Every company that provides an OAuth auth (as Google, Facebook, Amazon, Github, etc.) will give you the documentation instructions about how doing it the proper way.

Anyway, you will have to own your own authentication logic that will serve any of the options described, and you will have to implement each of them, one by one. After authenticating your user, you will have to keep the created session as usual in any application.