PHP code example of nixphp / session

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

    

nixphp / session example snippets


session()->set('user_id', 42);

$userId = session()->get('user_id');

session()->forget('user_id');

session()->flash('success', 'Profile updated.');

 if ($message = session()->getFlash('success')): 

return [
    'session' => [
        'storage'             => 'default', // switch to 'database' when using nixphp/database
        'trust_proxy_headers' => false,
        'trusted_proxies'     => [],
        'database_table'      => 'sessions',
    ],
];

$session = app()->container()->get(Session::class);