PHP code example of abollinger / session

1. Go to this page and download the library: Download abollinger/session 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/ */

    

abollinger / session example snippets


composer 


use Abollinger\Session;

use Abollinger\Session;

// Instantiate the session manager
$session = new Session();

$session->login([
    "userId" => "exampleUser123",
    "token"  => "secureToken123"
]);

$isAuthenticated = $session->isLoggedAndAuthorized($isSameServer = true);

if ($isAuthenticated) {
    echo "User is authenticated!";
} else {
    echo "Authentication failed.";
}

$session->logout([
    "userId" => "exampleUser123"
]);

$session = new Session();

$session->login([
    "userId" => "exampleUser",
    "token"  => "exampleToken"
]);


if ($session->isLoggedAndAuthorized()) {
    echo "User is authenticated!";
} else {
    echo "Authentication failed.";
}

$session->logout([
    "userId" => "exampleUser"
]);