本文整理汇总了PHP中session类的典型用法代码示例。如果您正苦于以下问题:PHP session类的具体用法?PHP session怎么用?PHP session使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* @TODO - there has to be a less heavy way of doing this...
*/
public function init($username = null)
{
global $db, $cache, $plugins;
global $groupscache, $forum_cache, $fpermcache, $mybb, $cached_forum_permissions_permissions, $cached_forum_permissions;
if (!defined('IN_MYBB')) {
define('IN_MYBB', true);
}
@(include_once dirname(DOCROOT) . '/mies/inc/init.php');
@(include_once MYBB_ROOT . 'inc/class_session.php');
try {
ob_start();
if (isset($mybb)) {
$session = new \session();
$session->init();
$mybb->session =& $session;
$this->myBB = $mybb;
} else {
$this->myBB = new \stdClass();
$this->myBB->user = ['username' => null];
if ($this->app['config']['mybb']['allowRandom']) {
$this->myBB->user['username'] = $username;
}
}
ob_end_clean();
} catch (\Exception $e) {
throw new AuthenticationException('Could not initialize MYBB application for authentication.');
}
}
示例2: oauth_callback
function oauth_callback($config)
{
$aConfig = array('appid' => $config['appid'], 'appkey' => $config['appkey'], 'api' => 'get_user_info,add_topic,add_one_blog,add_album,upload_pic,list_album,add_share,check_page_fans,add_t,add_pic_t,del_t,get_repost_list,get_info,get_other_info,get_fanslist,get_idollist,add_idol,del_idol,get_tenpay_addr');
$sUrl = "https://graph.qq.com/oauth2.0/token";
$aGetParam = array("grant_type" => "authorization_code", "client_id" => $aConfig["appid"], "client_secret" => $aConfig["appkey"], "code" => $_GET["code"], "state" => $_GET["state"], "redirect_uri" => $_SESSION["URI"]);
unset($_SESSION["state"]);
unset($_SESSION["URI"]);
$sContent = get($sUrl, $aGetParam);
if ($sContent !== FALSE) {
$aTemp = explode("&", $sContent);
$aParam = $oauth_data = array();
foreach ($aTemp as $val) {
$aTemp2 = explode("=", $val);
$aParam[$aTemp2[0]] = $aTemp2[1];
}
$oauth_data["access_token"] = $aParam["access_token"];
$sUrl = "https://graph.qq.com/oauth2.0/me";
$aGetParam = array("access_token" => $aParam["access_token"]);
$sContent = get($sUrl, $aGetParam);
if ($sContent !== FALSE) {
$aTemp = array();
preg_match('/callback\\(\\s+(.*?)\\s+\\)/i', $sContent, $aTemp);
$aResult = json_decode($aTemp[1], true);
$session = new session();
$oauth_data['oauth_openid'] = $aResult["openid"];
$session->set('oauth_data', $oauth_data);
}
}
}
示例3: save_meta_boxes
/**
* Saves the metaboxes
* @global type $post_type
* @param type $post_id
* @return boolean
*/
public function save_meta_boxes($post_id)
{
global $post_type;
$session = new session();
if ('POST' !== strtoupper($session->server_var('REQUEST_METHOD'))) {
return false;
}
if ($post_type !== 'syn_rest_meal') {
return false;
}
$full_price = $session->post_var('full_price');
$small_plate_price = $session->post_var('small_plate_price');
$display_price = $session->post_var('display_price', 'off');
$calorie_count = $session->post_var('calorie_count');
$new_addition = $session->post_var('new_addition');
$healthy_option = $session->post_var('healthy_option');
$gluten_free = $session->post_var('gluten_free');
$spice_rating = $session->post_var('spice_rating');
update_post_meta($post_id, 'full_price', $full_price);
update_post_meta($post_id, 'small_plate_price', $small_plate_price);
update_post_meta($post_id, 'display_price', $display_price);
update_post_meta($post_id, 'calorie_count', $calorie_count);
update_post_meta($post_id, 'new_addition', $new_addition);
update_post_meta($post_id, 'healthy_option', $healthy_option);
update_post_meta($post_id, 'gluten_free', $gluten_free);
update_post_meta($post_id, 'spice_rating', $spice_rating);
}
示例4: validaLogin
function validaLogin()
{
$email = $_POST['email'];
$senha = $_POST['senha'];
echo '1';
if (!isset($email) || !isset($senha)) {
sessao_limpa();
}
echo '2';
if (strlen(trim($email)) == 0 || strlen(trim($senha) == 0)) {
header("Location: /login/error/msg/u_s");
}
echo '3';
$model = new model();
$query = "SELECT * FROM usuario WHERE email_usuario = '{$email}' AND senha_usuario = '{$senha}'";
$result = $model->readSQL($query);
$session = new session();
if ($result) {
$session->sessao_grava($result[0]['email_usuario'], $result[0]['id_usuario_tipo']);
header("Location: /index");
} else {
$session->sessao_limpa();
header("Location: /login/error/msg/u_s");
}
}
示例5: testsession2
public function testsession2()
{
$v = JSFW()->getVersion();
jiashu::loadLib('session');
$sess = new session();
JSFW()->setTplData('n', $sess->sessionStart()->getSession('testsession'))->setTplData('v', $v);
JSFW()->render('index');
}
示例6: logout
function logout()
{
global $CONF, $LNG, $TMPL;
require_once "{$CONF['path']}/sources/misc/session.php";
$session = new session();
$session->delete($_COOKIE['atsphp_sid_user_cp']);
$TMPL['content'] = $LNG['user_cp_logout_message'];
}
示例7: disconnectAction
/**
* @Route("/secured/disconnect")
* @Template()
*/
public function disconnectAction()
{
//On initialise la variable error a nul pour ne pas avoir de message d'erreur
$session = new session();
$session->invalidate();
return $this->redirect('/');
//On redirige vers l'accueil
}
示例8: index_action
public function index_action($pagina = 1)
{
$session = new session();
$session->sessao_valida();
$_SESSION['pagina'] = $pagina;
$this->smarty->assign('paginador', $this->mostraGrid());
$this->smarty->assign('title', 'Departamentos');
$this->smarty->display('departamento/index.tpl');
}
开发者ID:ErickMaeda,项目名称:controle-eventos-php-cow_tipping_dwarfs,代码行数:9,代码来源:departamentoController.php
示例9: checkSession
public function checkSession()
{
//Cette fonction sert à vérfier que l'utilisateur est connecté
$session = new session();
if ($session->isStarted()) {
return true;
} else {
return $this->render("loginBundle:default:login.html.twig", array('error' => "Veuillez vous connecter"));
}
}
示例10: checkLogin
function checkLogin()
{
$session = new session();
$login = $session->get("person_id");
if (isset($login)) {
return true;
} else {
return false;
}
}
示例11: save_meta_boxes
public function save_meta_boxes($post_id)
{
global $post_type, $wpdb;
$session = new session();
if ('POST' !== strtoupper($session->server_var('REQUEST_METHOD'))) {
return false;
}
if ($post_type !== 'syn_rest_reservation') {
return false;
}
$first_name = $session->post_var('first_name');
$last_name = $session->post_var('last_name');
$phone_number = $session->post_var('phone_number');
$email_address = $session->post_var('email_address');
$guests_count = $session->post_var('guests_count');
$reservation_date = $session->post_var('reservation_date');
$reservation_time = $session->post_var('reservation_time');
update_post_meta($post_id, 'first_name', $first_name);
update_post_meta($post_id, 'last_name', $last_name);
update_post_meta($post_id, 'phone_number', $phone_number);
update_post_meta($post_id, 'email_address', $email_address);
update_post_meta($post_id, 'guests_count', $guests_count);
update_post_meta($post_id, 'reservation_date', $reservation_date);
update_post_meta($post_id, 'reservation_time', $reservation_time);
$arrival_time = date('Y-m-d H:i:s', strtotime("{$reservation_date}, {$reservation_time}"));
update_post_meta($post_id, 'arrival_time', $arrival_time);
$title = 'Reservation: ' . $first_name . ' ' . $last_name;
$where = array('ID' => $post_id);
$wpdb->update($wpdb->posts, array('post_title' => $title), $where);
}
示例12: get_current_user
private function get_current_user($sessID)
{
$sess = new session($sessID);
if ($sess->Started()) {
$person = new person();
$person->load_current_user($sess->Get("personID"));
// update session_started, which affects session lifetime
$sess->Save();
return $person;
}
}
示例13: index_action
public function index_action()
{
$session = new session();
$session->sessao_valida();
$modelEvento = new eventoModel();
$resEvento = $modelEvento->getEvento('stat<>0');
//send the records to template sytem
$this->smarty->assign('evento', $resEvento);
$this->smarty->assign('title', 'Emissão de Crachá');
$this->smarty->assign('listacliente', null);
//call the smarty
$this->smarty->display('cracha/index.tpl');
}
示例14: index_action
public function index_action($pagina = 1)
{
$session = new session();
$session->sessao_valida();
$_SESSION['pagina'] = $pagina;
//list all records
$cidade_model = new cidadeModel();
//send the records to template sytem
$this->smarty->assign('title', 'Cidades');
$this->smarty->assign('paginador', $this->mostraGrid());
//call the smarty
$this->smarty->display('cidade/index.tpl');
}
示例15: notify
/**
* Methode qui va notifier une action
* Arguments:
* + $id: l'id de mon objet
* + $message: le message de notre notification
* + $nature: product | cms | categorie
* + $criticity: success - danger - warning - info
* nature: 0 mon compte, 1 product , 2 categories, 3 cms, 4 fournisseurs
*/
public function notify($id, $message, $nature = 'product', $criticity = "success")
{
// 1. Nous récupérons dans une variable $tabsession
// le tableau de notifications par sa nature
// $this->session->get('nature') permet de récupérer une information par sa clef
// le 2eme argument a la fonction get() permet d'initialiser un tableau vide
// si ma clefs en session n'existe pas
$tabsession = $this->session->get($nature, array());
// 2. Nous stockons dans ce tableau
// la notification avec un message, avec une criticité et une date
$tabsession[$id] = array('message' => $message, 'criticity' => $criticity, 'date' => new \DateTime("now"));
// 3. nous enregistrons le tableau des notifications en session
$this->session->set($nature, $tabsession);
}