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


PHP helpers\Session类代码示例

本文整理汇总了PHP中helpers\Session的典型用法代码示例。如果您正苦于以下问题:PHP Session类的具体用法?PHP Session怎么用?PHP Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     //turn on output buffering
     ob_start();
     //site address
     define('DIR', getenv('OPENSHIFT_ADDR'));
     //set default controller and method for legacy calls
     define('DEFAULT_CONTROLLER', 'welcome');
     define('DEFAULT_METHOD', 'index');
     //set the default template
     define('TEMPLATE', 'default');
     //set a default language
     define('LANGUAGE_CODE', 'en');
     //database details ONLY NEEDED IF USING A DATABASE
     define('DB_TYPE', 'mysql');
     define('DB_HOST', getenv('OPENSHIFT_MYSQL_DB_HOST') . ':' . getenv('OPENSHIFT_MYSQL_DB_PORT'));
     define('DB_PORT', getenv('OPENSHIFT_MYSQL_DB_PORT'));
     define('DB_NAME', getenv('OPENSHIFT_GEAR_NAME'));
     define('DB_USER', getenv('OPENSHIFT_MYSQL_DB_USERNAME'));
     define('DB_PASS', getenv('OPENSHIFT_MYSQL_DB_PASSWORD'));
     define('PREFIX', 'smvc_');
     //set prefix for sessions
     define('SESSION_PREFIX', 'smvc_');
     //optionall create a constant for the name of the site
     define('SITETITLE', 'V2.2');
     //optionall set a site email address
     //define('SITEEMAIL', '');
     //turn on custom error handling
     set_exception_handler('Core\\Logger::ExceptionHandler');
     set_error_handler('Core\\Logger::ErrorHandler');
     //set timezone
     date_default_timezone_set('Europe/London');
     //start sessions
     Session::init();
 }
开发者ID:hieunguyenbk,项目名称:AgriExtension,代码行数:35,代码来源:Config.php

示例2: register

 public function register()
 {
     if (Session::get('loggedin')) {
         Url::redirect('');
     }
     $data['title'] = "Registrace";
     $model = new \Models\Users();
     if (isset($_POST['submit'])) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         $repeatPassword = $_POST['repeatPassword'];
         $email = $_POST['email'];
         if ($password == $repeatPassword) {
             if (!$model->exists($username)) {
                 // array of values for new user
                 $postdata = array('name' => $username, 'pass' => Password::make($password), 'email' => $email);
                 $model->add($postdata);
                 Url::redirect('login');
             } else {
                 $error[] = 'Jméno je již zabráno. Zkuste prosím jiné';
             }
         } else {
             $error[] = 'Heslo a ověření hesla se neshodují. Zkuste je prosím vyplnit znovu.';
         }
     }
     View::renderTemplate('header', $data);
     View::render('auth\\register', $data, $error);
     View::renderTemplate('footer', $data);
 }
开发者ID:Lyman88,项目名称:Creepers,代码行数:29,代码来源:Auth.php

示例3: index

 public function index()
 {
     $data['title'] = $this->language->get('beheer klanten');
     $rechten = \Helpers\Session::get('rechten') - 1;
     $result = $this->getData('klanten', $rechten);
     $i = 1;
     foreach ($result as $key) {
         $data["users"] .= '
             <tr>
                 <td>' . $i . '</td>
                 <td>' . $key->voornaam . '</td>
                 <td>' . $key->tussenvoegsel . '</td>
                 <td>' . $key->achternaam . '</td>
                 <td>' . $key->email . '</td>
                 <td style="text-align: right">
                     <a href="#" data-id="' . $key->klant_id . '" class="EditRow"><i class="fa fa-pencil-square-o fa-lg"></i></a>&nbsp;
                     <a href="#" data-id="' . $key->klant_id . '" class="DeleteRow"><i class="fa fa-times fa-lg"></i></a>
                 </td>
             </tr>
         ';
         $i++;
     }
     View::renderTemplate('header', $data);
     View::render('beheer/beheerklanten', $data);
     View::renderTemplate('footer', $data);
 }
开发者ID:Aukevanoost,项目名称:zeilschooldewaai,代码行数:26,代码来源:beheerKlanten.php

示例4: __construct

 public function __construct()
 {
     //Включение буферизации вывода
     ob_start();
     //Адрес сайта
     define('DIR', 'http://rocketfiles.zz.mu/');
     //Контроллера и метода по-умолчанию
     define('DEFAULT_CONTROLLER', 'main');
     define('DEFAULT_METHOD', 'index');
     //Шаблон по-умолчанию
     define('TEMPLATE', 'default');
     //Настройки базы данных
     define('DB_TYPE', 'mysql');
     define('DB_HOST', 'localhost');
     define('DB_NAME', 'rf_database');
     define('DB_USER', 'rovnatt');
     define('DB_PASS', 'qaz312wsx');
     define('PREFIX', 'rf_');
     //Префикс для сессий
     define('SESSION_PREFIX', 'rf_');
     //Название сайта
     define('SITETITLE', 'Rocket Files');
     //Email адрес сайта
     define('SITEEMAIL', 'robot@rocketfiles.zz.mu');
     //Собственный обработчик ошибок
     set_exception_handler('Core\\Logger::ExceptionHandler');
     set_error_handler('Core\\Logger::ErrorHandler');
     //Часовой пояс
     date_default_timezone_set('Europe/Moscow');
     //Запуск сессий
     Session::init();
 }
开发者ID:Nattpyre,项目名称:rocketfiles,代码行数:32,代码来源:Config.php

示例5: create

 public function create()
 {
     Session::init();
     if (Session::get('username')) {
         if (Session::get('admin')) {
             Url::redirect('exec');
         }
     } else {
         Url::redirect('');
     }
     $data['title'] = 'Wishlist';
     $tripId = \helpers\Session::get("tripId");
     $data['applicants'] = $this->mab->get_wishlist($tripId);
     $data['roster'] = $this->mab->get_official_roster($tripId);
     foreach ($data['applicants'] as $applicants_info) {
         $applicants_info->age = $this->mab->get_age_at_time($applicants_info->dateOfBirth, date('Y-m-d', time()));
     }
     if (isset($_POST['draft'])) {
         $trip_id = $this->mab->verify_applicant($_POST['applicationId']);
         if ($trip_id == NULL) {
             $this->mab->add_to_trip($_POST['applicationId'], $tripId);
             $this->mab->applicant_becomes_person($_POST['applicationId']);
             $this->mab->person_becomes_trip_member($_POST['applicationId'], $tripId);
         } else {
             if ($trip_id == $tripId) {
                 echo 'This is your participant';
             } else {
                 echo 'Application has already been drafted.';
             }
         }
     }
     View::rendertemplate('header', $data);
     View::render('wishlist/wishlist', $data, $error);
     View::rendertemplate('footer', $data);
 }
开发者ID:rlh5z6,项目名称:MAB_draft_application,代码行数:35,代码来源:wishlist.php

示例6: applicationSpecificInitializations

 public function applicationSpecificInitializations()
 {
     /**
      * Application specific initializations
      */
     define('THIS_USER_ID', \Helpers\Session::get('user_id'));
 }
开发者ID:krishnasrikanth,项目名称:smvc-php7,代码行数:7,代码来源:Initialize.php

示例7: register

 public function register()
 {
     if (Session::get('logged')) {
         Url::redirect();
     }
     $data['title'] = 'הרשמה';
     if (isset($_POST['submit'])) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         $email = $_POST['email'];
         if ($username == '') {
             $error[] = 'שם משתמש הוא שדה נדרש';
         }
         if ($this->_model->get_user($username)) {
             $error[] = 'שם המשתמש תפוס, בעסה';
         }
         if ($password == '') {
             $error[] = 'צריך סיסמא כדי להירשם, אחרת כל אחד יוכל להיכנס במקומך...';
         }
         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $error[] = 'כדי להירשם צריך מייל, למקרה ששכחת את הסיסמא';
         }
         if (!$error) {
             $postdata = array('user_name' => $username, 'user_password' => Password::make($password), 'user_email' => $email);
             $this->_model->add_user($postdata);
             $this->login_user($username);
             //        Session::set('message','User Added');
             Url::redirect();
         }
     }
     View::renderTemplate('header', $data);
     View::render('register', $data, $error);
     View::renderTemplate('footer', $data);
 }
开发者ID:Zed3,项目名称:foodie,代码行数:34,代码来源:Auth.php

示例8: handleFirstStep

 public function handleFirstStep($post)
 {
     /*
      *   @todo: xss security
      *   @todo: csrf security
      *   @todo: gump validation
      */
     $name = $post['group_name'];
     $descr = $post['group_descr'];
     if (strlen($name) < 4) {
         $error[] = 'Group name is too short.';
     } else {
         $check = $this->getGroupName($name);
         if (strtolower($check[0]->nume) == strtolower($name)) {
             $error[] = 'Group name already taken.';
         }
     }
     $tokenString = hash('sha256', mt_rand());
     $groupData = array('id_autor' => Session::get('id'), 'nume' => $name, 'descr' => $descr, 'completed' => $tokenString);
     if (!isset($error)) {
         $this->db->insert('grupuri', $groupData);
         setcookie('unfinished_group', $tokenString, time() + COOKIE_RUNTIME);
         Url::redirect(DIR . 'teacher/new-group-2', true);
     }
     return $error;
 }
开发者ID:umihnea,项目名称:e-learning.inkdrop,代码行数:26,代码来源:GroupModel.php

示例9: setSession

 public function setSession($token, $u_id, $role)
 {
     Session::set('loggedin', true);
     Session::set('fb_token', $token);
     Session::set('fb_user_id', $u_id);
     Session::set('fb_role', $role);
 }
开发者ID:fabiensebban,项目名称:the-pic-contest,代码行数:7,代码来源:Login.php

示例10: __construct

 public function __construct()
 {
     ob_start();
     define('DIR', 'http://meteo-colmar.fr/');
     define('DEFAULT_CONTROLLER', 'StaticPages');
     define('DEFAULT_METHOD', 'index');
     define('TEMPLATE', 'default');
     define('LANGUAGE_CODE', 'fr');
     define('DB_TYPE', 'mysql');
     define('DB_HOST', '***');
     define('DB_NAME', '***');
     define('DB_USER', '***');
     define('DB_PASS', '***');
     define('SESSION_PREFIX', 'smvc_');
     define('SITETITLE', 'Météo Colmar');
     define('SITEEMAIL', 'contact@meteo-colmar.fr');
     define('CAPTCHA_SITE_KEY', '***');
     define('CAPTCHA_SECRET_KEY', '***');
     define('NASA_API_KEY', '***');
     define('FETE_API_KEY', '***');
     set_exception_handler('Core\\Logger::ExceptionHandler');
     set_error_handler('Core\\Logger::ErrorHandler');
     date_default_timezone_set('Europe/London');
     Session::init();
 }
开发者ID:XxP1asmaxX,项目名称:MeteoColmar,代码行数:25,代码来源:Config.php

示例11: __construct

 public function __construct()
 {
     //turn on output buffering
     ob_start();
     //base path
     define('DIR', 'http://localhost/docstify/');
     //set default controller and method for legacy calls
     define('DEFAULT_CONTROLLER', 'welcome');
     define('DEFAULT_METHOD', 'index');
     //set the default template
     define('TEMPLATE', 'default');
     //set a default language
     define('LANGUAGE_CODE', 'es');
     //database details ONLY NEEDED IF USING A DATABASE
     define('DB_TYPE', 'mysql');
     define('DB_HOST', 'localhost');
     define('DB_NAME', 'dbname');
     define('DB_USER', 'root');
     define('DB_PASS', 'password');
     define('PREFIX', 'smvc_');
     //set prefix for sessions
     define('SESSION_PREFIX', '');
     //optionall create a constant for the name of the site
     define('SITETITLE', 'Docstify');
     //optionall set a site email address
     //define('SITEEMAIL', '');
     //turn on custom error handling
     set_exception_handler('Core\\Logger::ExceptionHandler');
     set_error_handler('Core\\Logger::ErrorHandler');
     //set timezone
     date_default_timezone_set('America/Mexico_City');
     //start sessions
     Session::init();
 }
开发者ID:alejandrozepeda,项目名称:docstify,代码行数:34,代码来源:Config.php

示例12: index

 public function index()
 {
     if (!Session::get('loggedin')) {
         Url::redirect('login');
     }
     if (isset($_POST['submit']) && $_FILES['fileToUpload']['size'] > 0) {
         $name = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName'];
         $price = !isset($_POST['productPrice']) || trim($_POST['productPrice']) == '' ? 0 : floatval($_POST['productPrice']);
         $description = !isset($_POST['productDescription']) || trim($_POST['productDescription']) == '' ? '' : $_POST['productDescription'];
         $target_dir = "uploads/";
         $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
         $uploadOk = 1;
         $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
         // Check if image file is a actual image or fake image
         if (isset($_POST["submit"])) {
             $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
             if ($check !== false) {
                 //echo "File is an image - " . $check["mime"] . ".";
                 $uploadOk = 1;
             } else {
                 //echo "File is not an image.";
                 $uploadOk = 0;
             }
         }
         // Check if file already exists
         if (file_exists($target_file)) {
             $error = "Sorry, file already exists." . $error;
             $uploadOk = 0;
         }
         // Check file size
         if ($_FILES["fileToUpload"]["size"] > 500000) {
             $error = "Sorry, your file is too large." . $error;
             $uploadOk = 0;
         }
         // Allow certain file formats
         if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
             $error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error;
             $uploadOk = 0;
         }
         // Check if $uploadOk is set to 0 by an error
         if ($uploadOk == 0) {
             $error = "Sorry, your file was not uploaded." . $error;
             // if everything is ok, try to upload file
         } else {
             //if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], str_replace(' ','-',strtolower($target_file)))) {
             //echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
             $product['product'] = array('name' => $name, 'price' => $price, 'description' => $description, 'lastUpdate' => date('Y-m-d G:i:s'));
             $product['image'] = array('image' => file_get_contents($_FILES['fileToUpload']['tmp_name']), 'size' => $_FILES["fileToUpload"]["size"], 'type' => $imageFileType);
             $this->_model->insertProduct($product);
             //unlink(str_replace(' ','-',strtolower($target_file)));
         }
     }
     Hooks::addHook('js', 'Controllers\\menu@indexJS');
     Hooks::addHook('css', 'Controllers\\menu@indexCss');
     $data['title'] = 'index';
     $data['username'] = Session::get('username');
     View::rendertemplate('header', $data);
     View::render('menu/index', $data, $error);
     View::rendertemplate('footer', $data);
 }
开发者ID:pacozaa,项目名称:simple-mvc-framework-inventory,代码行数:60,代码来源:menu.php

示例13: __construct

 public function __construct()
 {
     parent::__construct();
     if (!Session::get('loggedin')) {
         Url::redirect('login');
     }
 }
开发者ID:alejandrozepeda,项目名称:reaching-outdoors,代码行数:7,代码来源:Dashboard.php

示例14: runCookieLogin

 public function runCookieLogin()
 {
     $cookie = isset($_COOKIE['rememberme']) ? $_COOKIE['rememberme'] : '';
     if (!$cookie) {
         $error[] = "Invalid cookie. #1";
         return $error;
     }
     list($user_id, $token, $hash) = explode(':', $cookie);
     if ($hash !== hash('sha256', $user_id . ':' . $token)) {
         $error[] = "Invalid cookie. #2";
         return $error;
     }
     if (empty($token)) {
         $error[] = "Invalid cookie. #3";
         return $error;
     }
     $data = $this->getMemberCookie($token);
     print_r($data[0]);
     if (isset($data[0])) {
         Session::set('id', $data[0]->idAutori);
         Session::set('username', $data[0]->nume_login);
         Session::set('loggedin', true);
         Session::set('level', 'teacher');
         $error[] = 'Cookie login successful.';
         return $error;
     } else {
         $error[] = "Invalid cookie. #4";
         return $error;
     }
 }
开发者ID:umihnea,项目名称:e-learning.inkdrop,代码行数:30,代码来源:TeacherMember.php

示例15: index

 public function index()
 {
     \helpers\Session::init();
     if (\helpers\Session::get('username')) {
         if (\helpers\Session::get('admin')) {
             \helpers\url::redirect('exec');
         } else {
             \helpers\url::redirect('welcome');
         }
     }
     if ($_POST['submit']) {
         $is_valid = \helpers\gump::is_valid($_POST, array('fname' => 'required|alpha', 'lname' => 'required|alpha', 'dob' => 'required', 'gender' => 'required', 'year' => 'required', 'email' => 'required|valid_email', 'phone' => 'required', 'stunum' => 'required|numeric', 'issue1' => 'required', 'issue2' => 'required', 'issue3' => 'required'));
         if ($is_valid === true) {
             $this->submit();
         } else {
             $data['errors'] = $is_valid;
         }
     }
     $data['title'] = "Apply";
     $data['questions'] = $this->apply_model->getAllQuestions();
     $data['issues'] = $this->apply_model->getAllIssues();
     $data['options'] = $this->apply_model->getAllQuestionOptions();
     $data['colleges'] = $this->apply_model->getAllColleges();
     View::rendertemplate('header', $data);
     View::render('apply/apply', $data, $error);
     View::rendertemplate('footer', $data);
 }
开发者ID:rlh5z6,项目名称:MAB_draft_application,代码行数:27,代码来源:apply.php


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