本文整理汇总了PHP中SESSION函数的典型用法代码示例。如果您正苦于以下问题:PHP SESSION函数的具体用法?PHP SESSION怎么用?PHP SESSION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SESSION函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isConnected
function isConnected($URL = FALSE)
{
if (!SESSION("ZanUser")) {
redirect($URL);
}
return TRUE;
}
示例2: cacheSession
/**
* Sessions Helper
*
*
*
* @package ZanPHP
* @subpackage core
* @category helpers
* @author MilkZoft Developer Team
* @link http://www.zanphp.com/documentation/en/helpers/security_helper
*/
function cacheSession($cacheID)
{
if (SESSION("ZanUser")) {
return $cacheID . "." . SESSION("ZanUser");
}
return $cacheID . ".guest";
}
示例3: index
public function index()
{
if ($this->_get('token') != session('token')) {
$this->error('非法操作');
}
$token_open = M('token_open')->field('queryname')->where(array('token' => session('token')))->find();
//dump($token_open);
if (!strpos($token_open['queryname'], 'api')) {
$this->error('您还开启该模块的使用权,请到功能模块中添加', U('Function/index', array('token' => session('token'), 'id' => session('wxid'))));
}
$data = D('Api');
$this->assign('api', $data->where(array('token' => session('token'), 'uid' => session('uid')))->find());
if (IS_POST) {
$_POST['uid'] = SESSION('uid');
$_POST['token'] = SESSION('token');
//if(empty($_POST['home']))unset($_POST['home']);
if ($data->create()) {
if ($data->add()) {
$this->success('操作成功');
} else {
$this->error('服务器繁忙,请稍候再试');
}
} else {
$this->error($data->getError());
}
} else {
$this->display();
}
}
示例4: _initialize
public function _initialize()
{
if (!SESSION('?ADMIN_STATE')) {
$this->redirect('Admin/Login/index');
}
$this->webTitle = '后台管理';
}
示例5: editOrSave
private function editOrSave($action)
{
$validations = array("title" => "required", "URL" => "ping");
if (POST("code")) {
unset($validations["URL"]);
}
$data = array("ID_User" => SESSION("ZanUserID"), "Start_Date" => now(4), "End_Date" => now(4) + 2419200);
if ($action === "edit") {
$this->Data->ignore("banner");
}
$this->data = $this->Data->proccess($data, $validations);
if (isset($this->data["error"])) {
return $this->data["error"];
}
if (FILES("image", "name")) {
if (POST("banner")) {
@unlink(POST("banner"));
}
$dir = "www/lib/files/images/ads/";
$this->Files = $this->core("Files");
$this->data["Banner"] = $this->Files->uploadImage($dir, "image", "normal");
if (!$this->data["Banner"]) {
return getAlert("Upload error");
}
} else {
if (!isset($this->data["Code"])) {
return getAlert("You need to upload an image or write the ad code");
}
}
}
示例6: editOrSave
private function editOrSave($action)
{
$validations = array("exists" => array("Slug" => slug(POST("title", "clean")), "Year" => date("Y"), "Month" => date("m"), "Day" => date("d"), "Language" => POST("language")), "title" => "required", "content" => "required");
$this->categories = POST("categories");
$this->tags = POST("tags");
$this->URL = PATH("blog/" . date("Y")) . "/" . date("m") . "/" . date("d") . "/" . slug(POST("title", "clean"));
$this->muralExist = POST("mural_exist");
$this->Files = $this->core("Files");
$this->mural = FILES("mural");
if ($this->mural["name"] !== "") {
$dir = "www/lib/files/images/mural/";
$this->mural = $this->Files->uploadImage($dir, "mural", "mural");
if (is_array($this->mural)) {
return $this->mural["alert"];
}
}
$dir = "www/lib/files/images/blog/";
$this->image = $this->Files->uploadImage($dir, "image", "resize", TRUE, TRUE, FALSE);
$data = array("ID_User" => SESSION("ZanUserID"), "ID_URL" => 1, "Slug" => slug(POST("title", "clean")), "Content" => POST("content", "clean"), "Author" => SESSION("ZanUser"), "Year" => date("Y"), "Month" => date("m"), "Day" => date("d"), "Image_Small" => isset($this->image["small"]) ? $this->image["small"] : NULL, "Image_Medium" => isset($this->image["medium"]) ? $this->image["medium"] : NULL, "Pwd" => POST("pwd") ? POST("pwd", "encrypt") : NULL, "Start_Date" => now(4), "Text_Date" => now(2));
$this->Data->ignore(array("categories", "tags", "mural_exists", "mural", "pwd", "category", "language_category", "application", "mural_exist"));
$this->data = $this->Data->proccess($data, $validations);
if (isset($this->data["error"])) {
return $this->data["error"];
}
}
示例7: getOnlineUsers
function getOnlineUsers()
{
global $Load;
$Db = $Load->core("Db");
$date = time();
$time = 10;
$time = $date - $time * 60;
$IP = getIP();
$user = SESSION("ZanUser");
$Db->deleteBySQL("Start_Date < {$time}", "users_online_anonymous");
$Db->deleteBySQL("Start_Date < {$time}", "users_online");
if ($user) {
$users = $Db->findBy("User", $user, "users_online");
if (!$users) {
$Db->insert("users_online", array("User" => $user, "Start_Date" => $date));
} else {
$Db->updateBySQL("users_online", "Start_Date = '{$date}' WHERE User = '{$user}'");
}
} else {
$users = $Db->findBy("IP", $IP, "users_online_anonymous");
if (!$users) {
$Db->insert("users_online_anonymous", array("IP" => $IP, "Start_Date" => $date));
} else {
$Db->updateBySQL("users_online", "Start_Date = '{$date}' WHERE IP = '{$IP}'");
}
}
}
示例8: insert
public function insert()
{
$tj = M('Huadianposter')->where(array('token' => SESSION('token'), 'subestatename' => $_POST['subestatename']))->count();
if ($tj == 0) {
$this->all_insert();
} else {
$this->error('操作失败,已有记录!请删除原有分类海报!', U(MODULE_NAME . '/index'));
}
}
示例9: insert
public function insert()
{
$tj = M('Cosmetology')->where(array('token' => SESSION('token')))->count();
if ($tj == 0) {
$this->all_insert();
} else {
$this->error('操作失败', U(MODULE_NAME . '/index'));
}
}
示例10: editOrSave
private function editOrSave()
{
$validations = array("title" => "required", "URL" => "ping");
$data = array("ID_User" => SESSION("ZanUserID"));
$this->data = $this->Data->proccess($data, $validations);
if (isset($this->data["error"])) {
return $this->data["error"];
}
}
示例11: getTwitterUser
function getTwitterUser($oauthToken, $Twitter)
{
$Twitter->setToken($oauthToken);
$accessToken = $Twitter->getAccessToken();
$Twitter->setToken($accessToken->oauth_token, $accessToken->oauth_token_secret);
SESSION("ZanUserServiceAccessToken", $accessToken->oauth_token);
SESSION("ZanUserServiceAccessTokenSecret", $accessToken->oauth_token_secret);
$data = $Twitter->get_accountVerify_credentials();
return array("service" => "twitter", "serviceID" => $data->id, "username" => $data->screen_name, "name" => $data->name, "email" => null, "birthday" => null, "avatar" => $data->profile_image_url_https);
}
示例12: editOrSave
private function editOrSave()
{
$validations = array("exists" => array("Slug" => slug(POST("title", "clean")), "Language" => POST("language")), "title" => "required", "content" => "required");
$data = array("ID_User" => SESSION("ZanUserID"), "Slug" => slug(POST("title", "clean")), "Content" => POST("content", "clean"), "Start_Date" => now(4), "Text_Date" => now(2));
$this->data = $this->Data->proccess($data, $validations);
if (isset($this->data["error"])) {
return $this->data["error"];
}
return FALSE;
}
示例13: checkLoad
/**
* [登录信息检测]
* @param [array] $post [用户名,密码]
* @return [boolen] [description]
*/
public function checkLoad($post)
{
$uid = $this->where('user="' . $post['user'] . '" and pwd="' . md5($post['pwd']) . '"')->getField('uid');
if ($uid) {
SESSION('uid', $uid);
SESSION('user', $post[user]);
$res = true;
} else {
$res = false;
}
return $res;
}
示例14: apply_settings
function apply_settings($password, $password2, $realname)
{
global $LSP_URL;
if ($password != $password2) {
display_error('Password mismatch');
return false;
} else {
change_user(SESSION(), $realname, $password);
display_success('Account settings have been updated', array('<a href="">User Settings</a>', 'Success'), $LSP_URL . "?account=settings");
return true;
}
}
示例15: getFacebookUser
function getFacebookUser($code)
{
$response = file_get_contents("https://graph.facebook.com/oauth/access_token?client_id=" . FB_APP_ID . "&redirect_uri=" . encode(FB_APP_URL, true) . "&client_secret=" . FB_APP_SECRET . "&code=" . $code);
$params = null;
parse_str($response, $params);
if (isset($params["access_token"])) {
SESSION("ZanUserServiceAccessToken", $params["access_token"]);
$graphURL = "https://graph.facebook.com/me?fields=" . FB_APP_FIELDS . "&access_token=" . $params["access_token"];
$user = json_decode(file_get_contents($graphURL));
return array("serviceID" => $user->id, "username" => $user->username, "name" => $user->name, "email" => $user->email, "birthday" => $user->birthday, "avatar" => $user->picture->data->url);
}
return false;
}