1. Go to this page and download the library: Download oscarricardosan/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/ */
oscarricardosan / session example snippets
use Oscarricardosan\_Session_\_Session_;
class _MSession_ extends _Session_
{
/**
* @param bool $if_fails_close_session
* @return bool
*/
public static function verificateUserSession($if_fails_close_session= true)
{
$token_user = self::getAttr('user_id');
$user_data= // Code-sql that the user obtains from the session data.
if (password_verify($_POST['password'], $hash)) {
self::setUserData($user_data);
}else{
self::logout('/');
}
}
}
_MSession_::verificateUserSession();
print_r(_MSession_::userData());//Al user data
echo "Hola "._MSession_::userData()['name']; // Attribute in user data
//Close session and redirect to specific page.
_MSession_::logout('page_to_redirect.php');
//Clears the session but does not delete the flash variables
_MSession_::destroy(false);
//Destroy the session and delete the flash variables
_MSession_::destroy(true);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.