PHP code example of refkinscallv / session

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

    

refkinscallv / session example snippets


    

use RF\Session\Session;

// Initialize the session
$session = new Session();

// Start the session
$session->start();

// Set a session value
$session->set('user', 'John Doe');

// Get a session value
echo $session->get('user'); // Outputs: John Doe

// Check if a session key exists
if ($session->has('user')) {
    echo 'User session is set.';
}

// Get multiple session values
$values = $session->some(['user', 'role']);
echo $values['user']; // Outputs: John Doe

// Set flash data
$session->setFlash('message', 'Session started successfully!');

// Get and remove flash data
echo $session->getFlash('message'); // Outputs: Session started successfully!

public function __construct()

use RF\Session\Session;

// Initialize the session
$session = new Session();

// Set flash data
$session->setFlash('success', 'Your account has been created successfully!');

// Retrieve and remove flash data
echo $session->getFlash('success'); // Outputs: Your account has been created successfully!