1. Go to this page and download the library: Download acidjazz/summon 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/ */
acidjazz / summon example snippets
<?
/*
* sample code to:
* - log the user in
* - set a session cookie
* - store that hash/encoded string in a Summon array in the user model
* $results is an assoc array of
* - 'token' set as a cookie (default named token)
* - 'expires' when this session expires
* - 'sessions' an update list of all the users sessions to store in the DB
*/
$results = Summon\Summon::set($user->id(true), $user->sessions);
$user->sessions = $results['sessions'];
$user->save();
<?
/*
sample function to to:
- verify our cookies' validity
- extract our cookies payload
- verify once more in the DB
*/
public static function loggedIn() {
if ($data = Summon\Summon::check()) {
$user = new DBModelOfSomeSort\user($data['user_id']);
if ($user->exists() && isset($user->sessions[$data['hash']])) {
return $user;
}
}
return false;
}