PHP code example of krubio / perfect-session

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

    

krubio / perfect-session example snippets


use PerfectApp\Session\Session;

// Create a new session object
$session = new Session();

// Set a session variable
$session->set('username', 'johndoe');

// Get a session variable
$username = $session->get('username');

// Delete a session variable
$session->delete('username');

// Create a session object using a custom session data array
$sessionData = [
    'username' => 'johndoe',
    'email' => '[email protected]',
];

$session = new Session($sessionData);

// Get a session variable
$username = $session->get('username');

// Delete a session variable
$session->delete('username');