当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::init方法代码示例

本文整理汇总了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;
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:33,代码来源:SessionFactory.class.php

示例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;
 }
开发者ID:magicproof,项目名称:test,代码行数:12,代码来源:Session.php

示例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?");
     }
 }
开发者ID:bado57,项目名称:TryProject,代码行数:26,代码来源:Language.php

示例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;
     }
 }
开发者ID:roycncn,项目名称:Employers-Please-Look-at-here,代码行数:39,代码来源:admin_model.php

示例5: __construct

 public function __construct()
 {
     Session::init();
     if (Session::get('loggin') == false) {
         $this->login();
     }
 }
开发者ID:pratishshr,项目名称:Aawaaj,代码行数:7,代码来源:Auth_Controller.php

示例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;
 }
开发者ID:Ristee,项目名称:mvctest3,代码行数:33,代码来源:Login_Model.php

示例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();
 }
开发者ID:hillmediakft,项目名称:multijob,代码行数:7,代码来源:controller.php

示例8: render

 public function render($name)
 {
     Session::init();
     require 'views/navbar.php';
     require 'views/' . $name . '.php';
     require 'views/footer.php';
 }
开发者ID:Rasulbek,项目名称:asiacinema,代码行数:7,代码来源:View.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);
 }
开发者ID:mirfan,项目名称:Whirlpool,代码行数:35,代码来源:Whirlpool.php

示例10: __construct

 function __construct()
 {
     Session::init();
     Session::set('active', "about");
     Session::set('title', "О нас");
     parent::__construct();
 }
开发者ID:Rasulbek,项目名称:asiacinema,代码行数:7,代码来源:About.php

示例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);
 }
开发者ID:rlh5z6,项目名称:MAB_draft_application,代码行数:28,代码来源:application_analytics.php

示例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');
 }
开发者ID:spelgrift,项目名称:imageman,代码行数:27,代码来源:login_model.php

示例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;
     }
 }
开发者ID:uethackathon,项目名称:uethackathon2015_team5,代码行数:32,代码来源:login.php

示例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');
     }
 }
开发者ID:saptharsh,项目名称:Project-Management-App,代码行数:30,代码来源:login_model.php

示例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) {
     }
 }
开发者ID:TechDevMX,项目名称:TierraBaldia,代码行数:34,代码来源:SessionWrapper.php


注:本文中的Session::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。