} } catch (InvalidArgumentException $e) { return false; } } function is_logged_in() { if (isset($_SESSION['user_id'], $_SESSION['username'], $_SESSION['login_string'])) { $user_id = $_SESSION['user_id']; $login_string = $_SESSION['login_string']; // Get the user-agent string of the user. $user_browser = $_SERVER['HTTP_USER_AGENT']; $dbManager = new DbSessionManager(); $user = $dbManager->get_user_by_id($user_id); if ($user) { $login_check = hash('sha512', $user->getPassword() . $user_browser); if ($login_check == $login_string) { return true; } else { return false; } } else { return false; } } else { return false; } } $session = new session(); $session->start_session("s_");
############################################################# ob_start(); // Get install folder include_once "install_folder.php"; // Set session duration. $expire_time = 60 * 30; // seconds * minutes include "debug.php"; if (!isset($_SERVER['DOCUMENT_ROOT'])) { $path = $_SERVER['DOCUMENT_ROOT'] = str_replace('\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0 - strlen($_SERVER['PHP_SELF']))); } else { $path = $_SERVER['DOCUMENT_ROOT']; } $path = $path . '/' . $install_directory_name; // Include DB connection. include_once $path . '/API/database.php'; // Include session data. if (isset($control_panel_session)) { include_once $path . '/API/session.class_affiliates.php'; } else { include_once $path . '/API/session.class.php'; } // Include sanitation functions. if (!isset($exclude_validation)) { include_once $path . '/includes/validation_functions.php'; } // Activate session. $session = new session(); $session->start_session("_s", false); // Include global data. include $path . '/API/data.php';
function sec_session_start() { require 'session.class.php'; $session = new session(); $session->start_session('_s', SECURE); }
<?php require 'session.class.php'; $session = new session(); $session->start_session('_s', false); $_SESSION['something'] = 'A value.'; echo $_SESSION['something'];