1. Go to this page and download the library: Download ph-7/cookiesession 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/ */
ph-7 / cookiesession example snippets
use PH7\CookieSession\Session\Session;
$oSession = new Session;
$oSession->set('lang_pref', 'English');
// Create some sessions with an array
$aData = [
'my_session' => 'The value',
'another_session' => 'Another value',
'my_name' => 'Pierre-Henry'
];
// Add these sessions
$oSession->set($aData);
// Get session
echo $oSession->get('lang_pref'); // Will display 'English'
echo $oSession->get('another_session'); // Will display 'Another value'
echo ($oSession->exists('my_name')) ? $oSession->get('my_name') : 'Well, well, we dont have a name in the session'; // Will display 'Pierre-Henry'
$oSession->remove('my_name'); // Remove 'my_name' session
echo $oSession->get('my_name'); // Will display nothing (empty string) as 'my_name' session has been removed
use PH7\CookieSession\Cookie\Cookie;
$oCookie = new Cookie;
$oCookie->set('mycookie', 'Amazing Value!');
// Create some cookies in array
$aCookies = [
'name' => 'Pierre-Henry',
'city' => 'Manchester',
'job' => 'Software Engineer'
];
$oCookie->set($aCookies);
if ($oCookie->exists($aCookies)) {
echo 'All the following cookies exist: ' . implode(', ', $aCookies);
}
echo $oCookie->get('name'); // Will display 'Pierre-Henry'
echo $oCookie->get('mycookie'); // Will display 'Amazing Value!'
$oCookie->remove($aCookies); // Remove all cookies
echo $oCookie->get('name'); // Will display nothing (empty string)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.