PHP code example of koded / session

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

    

koded / session example snippets


[
    'session' => [
        // your ini "session." overwrites, without "session." prefix
    ]
]

// your middleware stack
$middleware = [
    SessionMiddleware::class
];

session()->get('key');
session()->set('key', 'value');
// etc.

// in your configuration file

return [
    'session' => [
        'save_handler' => 'redis | memcache'
    ]
]

[
    'session' => [
        'save_handler' => 'redis'
        
        // OPTIONAL, these are the defaults
        'host' => 'localhost',
        'port' => 6379,
        'timeout' => 0.0,
        'retry' => 0,
        'db' => 0,
        
        'prefix' => 'sess:',
        'serializer' => 'php', // or "json"
        'binary' => false,     // TRUE for igbinary
    ]
]

[
    'session' => [
        'save_handler' => 'redis',
        'name'         => 'session-name',
        'prefix'       => 'sess:',

        // isolate the session data in other db
        'db'           => 1
    ]
]

[
    'session' => [
        'save_handler' => 'memcached',
        
        // OPTIONAL: defaults to ['127.0.0.1', 11211]
        // If you have multiple memcached servers
        'servers' => [
            ['127.0.0.1', 11211],
            ['127.0.0.1', 11212],
            ['127.0.0.2']
            ...
        ],
        
        // OPTIONAL: the options are not mandatory
        'options' => [
            ...
        ]
    ]
]

[
    'session' => [
        'save_handler' => 'memcached',
        'name'         => 'session-name',
        'prefix'       => 'sess.'
    ]
]

[
    'session' => [
        // OPTIONAL: defaults to "session_save_path()"
        // the path where to store the session data
        'save_path' => '/var/www/sessions',
        'serialize_handler' => 'php'
    ]
]

[
    'session' => [
        // really nothing,
        // skip this section in your configuration
    ]
]