PHP code example of lekoala / silverstripe-multi-devices-remember-me

1. Go to this page and download the library: Download lekoala/silverstripe-multi-devices-remember-me library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lekoala / silverstripe-multi-devices-remember-me example snippets


public function logIn($remember = false) {
		...

		// Only set the cookie if autologin is enabled
        RememberMeExtension::setDeviceCookie($this, $remember);
		// if($remember && Security::config()->autologin_enabled) {
		// 	// Store the hash and give the client the cookie with the token.
		// 	$generator = new RandomGenerator();
		// 	$token = $generator->randomToken('sha1');
		// 	$hash = $this->encryptWithUserSettings($token);
		// 	$this->RememberLoginToken = $hash;
		// 	Cookie::set('alc_enc', $this->ID . ':' . $token, 90, null, null, null, true);
		// } else {
		// 	$this->RememberLoginToken = null;
		// 	Cookie::force_expiry('alc_enc');
		// }

        ...

public static function currentUserID() {
    $id = Session::get("loggedInAs");
    if(!$id && !self::$_already_tried_to_auto_log_in) {
        RememberMeExtension::autoLoginFromDevice();
        $id = Session::get("loggedInAs");
    }

    return is_numeric($id) ? (int) $id : 0;
}