本文整理汇总了PHP中helpers\Session::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::set方法的具体用法?PHP Session::set怎么用?PHP Session::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpers\Session
的用法示例。
在下文中一共展示了Session::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit($id)
{
$data['title'] = 'Edit Member';
$data['row'] = $this->model->get_member($id);
if (isset($_POST['submit'])) {
if ($_POST['token'] != Session::get('token')) {
Url::redirect('admin/login');
}
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
if ($username == '') {
$error[] = 'Username is required';
}
if ($password == '') {
$error[] = 'Password is required';
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error[] = 'Email is not valid';
}
if (!$error) {
$postdata = array('member_username' => $username, 'member_password' => Password::make($password), 'member_email' => $email);
$where = array('member_id' => $id);
$this->model->update_member($postdata, $where);
Session::set('message', 'Member Updated');
Url::redirect('admin/members');
}
}
View::renderadmintemplate('header', $data);
View::render('admin/members/edit', $data, $error);
View::renderadmintemplate('footer', $data);
}
示例2: 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);
}
示例3: login
public function login()
{
Hooks::addHook('js', 'Controllers\\auth@js');
Hooks::addHook('css', 'Controllers\\auth@css');
$error = 'hi';
$success = 'hi';
if (Session::get('loggedin')) {
Url::redirect();
}
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
//validation
if (Password::verify($password, $this->_model->getHash($username)) == false) {
$error[] = 'Wrong username or password';
}
//if validation has passed carry on
if (!$error) {
Session::set('loggedin', true);
Session::set('username', $username);
Session::set('memberID', $this->_model->getID($username));
$data = array('lastLogin' => date('Y-m-d G:i:s'));
$where = array('memberID' => $this->_model->getID($username));
$this->_model->update($data, $where);
$error = 'hi';
Url::redirect();
}
}
$data['title'] = 'Login';
View::rendertemplate('header', $data);
View::render('auth/login', $data, $error, $success);
View::rendertemplate('footer', $data);
}
示例4: index
/**
* Define Index page title and load template files
*/
public function index()
{
// Get the selected offering year
$offeringYear = $_POST['courseId'];
// Set view data
$data['title'] = 'Course Selection';
$data['student_name'] = \Helpers\Session::get('Name');
$data['javascript'] = array('course');
$data['course_list'] = $this->course->getCourseOfferings($offeringYear);
// If form has been submitted
if (isset($_POST['submit'])) {
$selectedYear = $_POST['yearDropdown'];
$courses = $_POST['courses'];
\Helpers\Session::set('OfferingYear', $selectedYear);
// If an offering year has been selected
if ($selectedYear) {
// If at least one course has been selected
if (count($courses)) {
// Store the selected courses in the user's session
\Helpers\Session::set('SelectedCourses', $courses);
// Redirect to course confirmation page page
\Helpers\Url::redirect('Confirmation');
} else {
$error[] = 'You must select at least one course';
}
} else {
$error[] = 'You must select an offering year';
}
}
// Render view
View::renderTemplate('header', $data);
View::render('course/selection', $data, $error);
View::renderTemplate('footer', $data);
}
示例5: login
/**
* Define login page title and load template files
*/
public function login()
{
if (Session::get('loggedin')) {
Url::redirect('');
}
$data['title'] = 'Přihlášení';
$model = new \Models\Users();
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
// verify password using helper class Password
if (Password::verify($password, $model->getPass($username))) {
Session::set('loggedin', true);
Session::set('username', $username);
Session::set('role', $model->getRole($username));
Session::set('userID', $model->getID($username));
if (Session::get('role') == "admin") {
Url::redirect('admin');
} else {
if (Session::get('role') == "recenzent") {
Url::redirect('ratings');
} else {
Url::redirect('tales');
}
}
} else {
$error[] = 'Špatné jméno nebo heslo';
}
}
View::renderTemplate('header', $data);
View::render('auth\\login', $data, $error);
View::renderTemplate('footer', $data);
}
示例6: login
public function login()
{
if (Session::get('loggedin')) {
Url::redirect('admin');
}
$model = new \Models\Admin\Auth();
$data['title'] = 'Login';
if (isset($_POST['submit'])) {
$username = $_POST['member_username'];
$password = $_POST['member_password'];
if (Password::verify($_POST['member_password'], $model->getHash($_POST['member_username'])) == 0) {
$error[] = 'Wrong username of password';
} else {
$data['user_infos'] = $model->get_user_infos($_POST['member_username']);
Session::set('member_id', $data['user_infos'][0]->member_id);
Session::set('member_username', $username);
Session::set('member_password', '' . $password . '');
Session::set('loggedin', true);
Url::redirect('admin');
}
}
View::renderadmintemplate('loginheader', $data);
View::render('admin/login', $data, $error);
View::renderadmintemplate('footer', $data);
}
示例7: 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;
}
}
示例8: login
public function login()
{
if (Session::get('loggedin')) {
Url::redirect('admin-panel');
}
$data['title'] = 'Login';
if (isset($_POST['submit'])) {
$correo = $_POST['correo'];
$password = $_POST['password'];
if ($correo == '' || !isset($correo)) {
$data['error'][0] = 'Correo es un campo obligatorio';
}
if ($password == '' || !isset($password)) {
$data['error'][1] = 'Password es un campo obligatorio';
}
if (Password::verify($password, $this->_model->getHash($correo)) == false) {
$data['error'][2] = 'Correo o password incorrectos';
}
if (!$data['error']) {
$data['usuario'] = $this->_model->getUsuario($correo);
Session::set('loggedin', true);
Session::set('idUsuario', $data[usuario][0]->idUsuario);
Session::set('nombre', $data[usuario][0]->nombre);
Session::set('apellidoPaterno', $data[usuario][0]->apellidoPaterno);
$dataUsuario = array('fechaConexion' => date("Y-m-d H:i:s"));
$where = array('correo' => $correo);
$this->_model->updateUsuario($dataUsuario, $where);
Url::redirect('admin-panel');
}
}
View::renderTemplate('header', $data);
View::render('Auth/Login', $data);
View::renderTemplate('footer', $data);
}
示例9: index
/**
* Define Index page title and load template files
*/
public function index()
{
$data['title'] = $this->language->get('welcome_text');
$data['welcome_message'] = $this->language->get('welcome_message');
Session::set('error', 'das');
View::renderTemplate('header', $data);
View::render('dashboard/dashboard', $data);
View::renderTemplate('footer', $data);
}
示例10: change
/**
* Change the Framework Language.
*/
public function change($language)
{
// Only set language if it's in the Languages array
if (preg_match('/[a-z]/', $language) && in_array($language, CoreLanguage::$codes)) {
Session::set('language', ucfirst($language));
// Store the current Language into Cookie.
Cookie::set(PREFIX . 'language', $language);
}
Url::redirect();
}
示例11: checkCookie
protected function checkCookie()
{
if (isset($_COOKIE['rf_user_cookie']) && isset($_COOKIE['rf_user_id_cookie']) && isset($_COOKIE['rf_user_pass_cookie'])) {
$result = $this->_user->checkUserCookie($_COOKIE['rf_user_cookie']);
if (\Helpers\Password::verify($_COOKIE['rf_user_pass_cookie'], $result[0]['password'])) {
\Helpers\Session::set('user', $_COOKIE['rf_user_cookie']);
\Helpers\Session::set('user_id', $_COOKIE['rf_user_id_cookie']);
}
}
}
示例12: makeToken
/**
* get CSRF token and generate a new one if expired
*
* @access public
* @static static method
* @return string
*/
public static function makeToken()
{
$max_time = 60 * 60 * 24;
// token is valid for 1 day
$stored_time = Session::get('csrf_token');
$csrf_token = Session::get('csrf_token_time');
if ($max_time + $stored_time <= time() || empty($csrf_token)) {
Session::set('csrf_token', md5(uniqid(rand(), true)));
Session::set('csrf_token_time', time());
}
return Session::get('csrf_token');
}
示例13: makeToken
/**
* get CSRF token and generate a new one if expired
*
* @access public
* @static static method
* @return string
*/
public static function makeToken()
{
$max_time = 60 * 60 * 24;
// token is valid for 1 day
$csrf_token = Session::get('csrf_token');
$stored_time = Session::get('csrf_token_time');
if ($max_time + $stored_time <= time() || empty($csrf_token)) {
Session::set('csrf_token', base64_encode(openssl_random_pseudo_bytes(32)));
// Secure Token Gen
Session::set('csrf_token_time', time());
}
return Session::get('csrf_token');
}
示例14: makeToken
/**
* Retrieve the CSRF token and generate a new one if expired.
*
* @access public
* @static static method
* @return string
*/
public static function makeToken($name = 'csrfToken')
{
$max_time = 60 * 60 * 24;
// token is valid for 1 day.
$csrf_token = Session::get($name);
$stored_time = Session::get($name . '_time');
$timestamp = time();
if ($max_time + $stored_time <= $timestamp || empty($csrf_token)) {
$hash = hash('sha512', Str::randomBytes());
Session::set($name, $hash);
Session::set($name . '_time', $timestamp);
}
return Session::get($name);
}
示例15: init
public static function init()
{
if (Session::exists('language')) {
// The Language was already set; nothing to do.
return;
} else {
if (Cookie::exists(PREFIX . 'language')) {
$cookie = Cookie::get(PREFIX . 'language');
if (preg_match('/[a-z]/', $cookie) && in_array($cookie, self::$codes)) {
Session::set('language', ucfirst($cookie));
}
}
}
}