本文整理汇总了PHP中Session::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::init方法的具体用法?PHP Session::init怎么用?PHP Session::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Returns the object of the active session.
* Tries to find an existing session.
* Otherwise creates a new session.
*
* @return Session $session
*/
public function get()
{
// get session id
$this->sessionID = $this->readSessionID();
$this->session = null;
// get existing session
if (!empty($this->sessionID)) {
$this->session = $this->getExistingSession($this->sessionID);
}
// create new session
if ($this->session == null) {
$this->session = $this->create();
}
self::$activeSession = $this->session;
// call shouldInit event
if (!defined('NO_IMPORTS')) {
EventHandler::fireAction($this, 'shouldInit');
}
// init session
$this->session->init();
// call didInit event
if (!defined('NO_IMPORTS')) {
EventHandler::fireAction($this, 'didInit');
}
return $this->session;
}
示例2: getInstance
/**
* get instance of Session
* @return Session
*/
public static function getInstance()
{
if (is_null(self::$_instance)) {
self::$_instance = new self();
}
self::$_instance->init();
return self::$_instance;
}
示例3: selectlanguage
function selectlanguage()
{
if ($_POST && $_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest") {
$sonuc = array();
$form = $this->load->otherClasses('Form');
Session::init();
$form->post("lang", true);
$dil = $form->values['lang'];
if ($dil == "tr" || $dil == "en" || $dil == "fr" || $dil == "ar" || $dil == "de" || $dil == "zh") {
if (isset($_SESSION['dil'])) {
unset($_SESSION['dil']);
Session::set("dil", $dil);
} else {
Session::set("dil", $dil);
}
} else {
//eğer dil yoksa
$dil = 'en';
Session::set("dil", $dil);
}
$sonuc["lang"] = $dil;
echo json_encode($sonuc);
} else {
die("Hacklemeye mi Çalışıyorsun pezevenk?");
}
}
示例4: login
/**
* Login Process (for Administrator)
*
* @return bool success state
* */
public function login()
{
//the first step checks
if (!isset($_POST['adminid']) or empty($_POST['adminid'])) {
$_SESSION["feedback_negative"][] = FEEDBACK_USERNAME_FIELD_EMPTY;
return false;
}
if (!isset($_POST['password']) or empty($_POST['password'])) {
$_SESSION["feedback_negative"][] = FEEDBACK_PASSWORD_FIELD_EMPTY;
return false;
}
//ready to verify
$sth = $this->db->prepare("SELECT adminid,\n\t\t\t\t\t\t\t\t\t\tadminName,\n\t\t\t\t\t\t\t\t\t\tpassword\n\t\t\t\t\t\t\t\t FROM admin\n\t\t\t\t\t\t\t\t WHERE adminid= :adminid");
$sth->execute(array(':adminid' => $_POST['adminid']));
$count = $sth->rowCount();
//if ther is NOT such result
if ($count != 1) {
$_SESSION["feedback_negative"][] = FEEDBACK_LOGIN_FIELD;
return false;
}
$result = $sth->fetch();
if ($_POST['password'] === $result->password) {
// set the user info into session
Session::init();
Session::set('admin_logged_in', true);
Session::set('adminid', $result->adminid);
Session::set('adminName', $result->adminName);
//rerurn true to make clear thar the login was successful
return true;
} else {
$_SESSION["feedback_negative"][] = FEEDBACK_PASSWORD_WRONG;
return false;
}
}
示例5: __construct
public function __construct()
{
Session::init();
if (Session::get('loggin') == false) {
$this->login();
}
}
示例6: run
public function run()
{
$login = $_POST['login'];
$password = $_POST['password'];
/* PDO */
$res = $this->db->prepare("SELECT userid, role FROM users WHERE\n login = :login AND password = :password");
$res->execute(array(':login' => $login, ':password' => Hash::create(HASH_METHOD, $password, HASH_PASSWORD_KEY)));
// $data = $res->fetchAll();
$count = $res->rowCount();
/* mysqli */
/*$res = $this->db->prepare("select id from users
where login = ?
and password = MD5(?)");
$res->bind_param("ss",$login,$password);
$res->execute();
$res->bind_result($ret);
$res->fetch();*/
$data = $res->fetch();
if ($count > 0) {
//login
Session::init();
Session::set('role', $data['role']);
Session::set('loggedIn', true);
Session::set('userid', $data['userid']);
header('Location:../dashboard');
exit;
} else {
//show an Error
header('Location:../login');
exit;
}
// return $ret;
}
示例7: __construct
function __construct()
{
Session::init();
$this->registry = Registry::get_instance();
// létrehozzuk a view objektumot és hozzárendeljük a $view tulajdonsághoz
$this->view = new View();
}
示例8: render
public function render($name)
{
Session::init();
require 'views/navbar.php';
require 'views/' . $name . '.php';
require 'views/footer.php';
}
示例9: init
/**
* @throws \Exception
*/
protected function init()
{
$this->setEnvironment();
// Load class aliases
$aliases = Config::get('aliases');
foreach ($aliases as $orig => $new) {
class_alias($orig, $new, true);
}
static::$container = new Container();
Session::init();
Request::init();
$this->initRouter();
$databaseConfig = Config::get('database');
if ($databaseConfig !== null && is_array($databaseConfig)) {
$this->capsule = new Capsule();
foreach ($databaseConfig as $name => $conf) {
if (array_key_exists('name', $conf) && strlen($conf['name']) > 0) {
$name = $conf['name'];
unset($conf['name']);
}
$this->capsule->addConnection($conf, $name);
}
$this->capsule->bootEloquent();
}
$hookConfig = Config::get('hooks');
if (is_array($hookConfig)) {
foreach ($hookConfig as $event => $callable) {
EventHandler::addListener($event, $callable);
}
}
EventHandler::triggerEvent('whirlpool-initialized', $this);
}
示例10: __construct
function __construct()
{
Session::init();
Session::set('active', "about");
Session::set('title', "О нас");
parent::__construct();
}
示例11: create
public function create()
{
Session::init();
if (Session::get('username')) {
if (!Session::get('admin')) {
Url::redirect('welcome');
}
} else {
Url::redirect('');
}
$data['title'] = 'Application Analytics';
$data['gender'] = $this->mab->get_gender();
$data['yearsInSchool'] = $this->mab->get_years_in_school();
$data['apps'] = $this->mab->get_apps_by_issue();
$data['apps1'] = $this->mab->get_apps_by_issue_rank(1);
$data['apps2'] = $this->mab->get_apps_by_issue_rank(2);
$data['apps3'] = $this->mab->get_apps_by_issue_rank(3);
$data['apps_by_college'] = $this->mab->get_apps_by_college();
$data['marketing_data'] = $this->mab->get_marketing_data();
$data['issues'] = $this->apply_model->getAllIssues();
if (isset($_POST['submit'])) {
$issueId = $_POST['issues'];
$data['issues_by_gender'] = $this->mab->get_issues_by_gender($issueId);
}
View::rendertemplate('exec_header', $data);
View::render('analytics/application_analytics', $data, $error);
View::rendertemplate('footer', $data);
}
示例12: run
public function run($static = false)
{
$form = new Form();
$form->post('login')->val('blank')->post('password')->val('blank');
if (!$form->submit()) {
// Error
$this->_error($static);
return false;
}
$data = $form->fetch();
$login = $data['login'];
$password = Hash::create('sha256', $data['password'], PASS_HASH_KEY);
$query = "SELECT userid, login, role FROM user WHERE login = :login AND password = :password";
if (!($result = $this->db->select($query, array(':login' => $login, ':password' => $password)))) {
$this->_error($static);
return false;
}
Session::init();
Session::set('userid', $result[0]['userid']);
Session::set('login', $result[0]['login']);
Session::set('role', $result[0]['role']);
Session::set('loggedIn', true);
if ($static) {
header('location:' . URL . 'dashboard');
}
echo json_encode('success');
}
示例13: index
/**
* Default method
* @return [type] [description]
*/
public function index()
{
if (Session::get('logined') !== null) {
if (Session::get('logined')) {
$this->getUserLogin();
exit;
}
}
$auth = new Authenticate();
if (isset($_POST['user_id']) && isset($_POST['id_token'])) {
$user_id = $_POST['user_id'];
$id_token = $_POST['id_token'];
if ($auth->checkLogin($user_id, $id_token)) {
Session::init();
Session::set('id_token', $id_token);
Session::set('user_id', $user_id);
Session::set('logined', true);
echo json_encode('success');
exit;
} else {
echo json_encode('need login with google ID');
exit;
}
} else {
echo json_encode('need login with google ID');
exit;
}
}
示例14: run
public function run()
{
/*
* md5 is a 32 bit hash
*/
$statement = $this->db->prepare("SELECT id, role FROM users WHERE login = :user AND password = :pass");
$statement->execute(array(':user' => $_POST['user'], ':pass' => Hash::create('sha256', $_POST['pass'], HASH_KEY)));
/*
* The Obj returned by $statement was 'Array of Arrays'
*/
$result = $statement->fetchAll();
//$statement returns an Array of objects
//print_r($result);
//echo '</br>';
$data = $result['0'];
//print_r($data);
//echo '</br>role='.$data['role'];
$count = $statement->rowCount();
if ($count > 0) {
//log in the user
Session::init();
Session::set('userid', $data['id']);
Session::set('role', $data['role']);
Session::set('loggedIn', true);
header('location: ../dashboard');
} else {
//show an error
header('location: ../login');
}
}
示例15: initialize
public static function initialize()
{
if (self::$initialized) {
return;
}
self::$initialized = true;
try {
// Initialize local session
Session::init();
if (!empty($_GET['logout'])) {
self::destroy();
Session::init();
}
if (!Session::userIsLoggedIn() && Request::cookie('remember_me')) {
if (!LoginModel::loginWithCookie(Request::cookie('remember_me'))) {
LoginModel::deleteCookie();
}
}
$currentUrl = $_SERVER['REQUEST_URI'];
$end = strpos($currentUrl, '?');
if ($end === false) {
$end = strpos($currentUrl, '#');
}
if ($end !== false) {
$currentUrl = substr($currentUrl, 0, $end);
}
// Initialize Facebook session
/*self::$facebookSession = new FacebookSessionWrapper(
Tools::getBaseUrl() . $currentUrl,
Tools::getBaseUrl() . '/logout/'
);*/
} catch (\Exception $ex) {
}
}