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


PHP cookie函数代码示例

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


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

示例1: __construct

 public function __construct()
 {
     if ($_GET['source'] && !cookie('source')) {
         cookie('source', trim($_GET['source']));
     }
     if (isset($_GET['spm']) && $_GET['spm']) {
         cookie('_spm', $_GET['spm'], array('expire' => 172800, 'domain' => '.wdwd.com', 'path' => '/'));
     }
     if (!session('?shop')) {
         $this->redirect('admin/passport/logout');
     }
     /*
     var_dump(session('shop'));
     exit;
     if (!session('?shop') || ('' == session('shop.mobile'))) {
         if (session('?user')) {
             $this->redirect('admin/passport/bind');
         }
         else {
             $this->redirect('admin/passport/logout');
         }
     }
     */
     $shop = session('shop');
     $shop['decode_shop_id'] = \Common\Lib\Idhandler::decode($shop['shop_id']);
     $this->passport = session('passport');
     $this->shop = $shop;
     $this->shop['mobile'] = $this->passport['loginname'];
     //print_r($this->shop);
     //print_r(session('passport'));
     parent::__construct();
 }
开发者ID:000LongMarch000,项目名称:wx,代码行数:32,代码来源:AdminController.class.php

示例2: receiveEvent

 private function receiveEvent($object)
 {
     $contentStr = "";
     switch ($object->Event) {
         case "subscribe":
             $contentStr = "欢迎关注方倍工作室";
             cookie('openid', $object->FromUserName . '');
             break;
         case "unsubscribe":
             $contentStr = "";
             break;
         case "CLICK":
             switch ($object->EventKey) {
                 case "天气北京":
                     $contentStr = "北京天气晴!";
                     break;
                 default:
                     $contentStr = "你点击了菜单: " . $object->EventKey;
                     break;
             }
             break;
         default:
             $contentStr = "receive a new event: " . $object->Event;
             break;
     }
     $resultStr = $this->transmitText($object, $contentStr);
     return $resultStr;
 }
开发者ID:licaikai,项目名称:baby,代码行数:28,代码来源:CallbackController.class.php

示例3: rememberMe

 public function rememberMe($userId, $password, $expire = 864000)
 {
     $token['userId'] = $userId;
     $token['verify'] = sha1(md5($password));
     cookie('token', $token, $expire);
     return 1;
 }
开发者ID:AlexanderFeng,项目名称:a-simple-question-and-answer-website,代码行数:7,代码来源:AutoLoginController.class.php

示例4: dealData

 public function dealData()
 {
     $username = I('username', null, 'htmlspecialchars');
     $password = I('password', null, 'htmlspecialchars');
     $remember = I('checkbox', 0, 'htmlspecialchars');
     if ($username != null && $password != null) {
         $data = M()->table('Admin')->where(array('username' => $username))->find();
         if ($data['username'] == $username && $data['password'] == md5($password)) {
             $_SESSION['username'] = $username;
             $_SESSION['password'] = $password;
             $_SESSION['remember'] = $remember;
             M()->table('Admin')->where('id=1')->setField('logintime', time());
             if ($remember == 1) {
                 cookie('remember', $username . ":" . $password, time() + 3600 * 24);
             }
             $this->redirect("Index/index", array("tab" => 1));
         } else {
             echo "<script> alert('用户名或密码错误!');parent.location.href='index.html'; </script>";
             exit;
         }
     } else {
         if ($username == null) {
             echo "<script> alert('用户名不能为空!');parent.location.href='index.html'; </script>";
             exit;
         } else {
             if ($password == null) {
                 echo "<script> alert('密码不能为空!');parent.location.href='index.html'; </script>";
                 exit;
             }
         }
     }
 }
开发者ID:priateStudio,项目名称:award,代码行数:32,代码来源:LoginAction.class.php

示例5: edit

 public function edit($id)
 {
     //get提交时 根据id查询出相应的数据进行回显
     if (IS_GET) {
         $rows = $this->model->find($id);
         //查询一条数据用find
         //分配数据到页面
         $this->assign($rows);
         $this->_edit_view_before();
         $this->assign("meta_title", "编辑{$this->meta_title}");
         //调用显示页面
         $this->display("edit");
     } else {
         //post提交时用create方法收集数据,并用save方法更新到数据库涨
         if ($this->model->create() !== false) {
             //有数据时进行更新操作
             if ($this->model->save($this->usePostParams ? I('post.') : '') !== false) {
                 //更新成功时跳转到cookie中保存的当前页面
                 $this->success("更新成功...", cookie("__nowurl__"));
                 return;
             }
             $this->error("更新失败.." . show_model_error($this->model));
         }
     }
 }
开发者ID:zaibuxingwojiiugodie,项目名称:shop,代码行数:25,代码来源:BaseController.class.php

示例6: getBrands

 /**
  * 列表查询
  */
 public function getBrands()
 {
     $m = D('Home/Brands');
     $brandslist = $m->queryBrandsByDistrict();
     cookie("bstreesAreaId3", I("areaId3"));
     $this->ajaxReturn($brandslist);
 }
开发者ID:hanxiansen,项目名称:wstmall,代码行数:10,代码来源:BrandsAction.class.php

示例7: loginCheck

 /**
  * 登录验证
  */
 public function loginCheck()
 {
     $name = $this->_post('name');
     $password = $this->_post('password');
     $user = M('user');
     $condition['name'] = $name;
     $data = $user->where($condition)->select();
     if ($data) {
         if ($data[0]['password'] == $password) {
             //验证成功
             session('user_id', $data[0]['id']);
             cookie('user_id', $data[0]['id'], 3600);
             //$this->display('Home:hometest');
             //$this->display('Home:home');
             header('location:' . $this->conf['APP_ROOT'] . 'Home/home');
         } else {
             //密码错误
             $message = '对不起,您的密码错误!';
             $this->assign('message', $message);
             $this->display('Login:loginFail');
         }
     } else {
         //用户名不存在
         $message = '对不起,用户名不存在!';
         $this->assign('message', $message);
         $this->display('Login:loginFail');
     }
 }
开发者ID:nyankosama,项目名称:OnlyMyBlog,代码行数:31,代码来源:LoginAction.class.php

示例8: _initialize

 public function _initialize()
 {
     if (!session("user_id")) {
         if (!cookie("user_id")) {
             $user_id = D("User")->user_add();
             cookie("user_id", $user_id, 36000000);
             cookie("token", md5(C("cookie_key") . $user_id), 36000000);
             session("user_id", $user_id);
         } else {
             $user_id = cookie("user_id");
             $token = cookie("token");
             if (md5(C("cookie_key") . $user_id) == $token) {
                 session("user_id", $user_id);
                 cookie("user_id", $user_id, 36000000);
                 cookie("token", md5(C("cookie_key") . $user_id), 36000000);
             } else {
                 $user_id = D("User")->user_add();
                 cookie("user_id", $user_id, 36000000);
                 cookie("token", md5(C("cookie_key") . $user_id), 36000000);
                 session("user_id", $user_id);
             }
         }
     } else {
         $user_id = session("user_id");
     }
     $user = D("user")->getuser($user_id);
     define('UID', $user_id);
     define('NAME', $user['name']);
 }
开发者ID:lvxiaolin,项目名称:xiaolin_game,代码行数:29,代码来源:CommController.class.php

示例9: edit

 /**
  * 修改菜单
  */
 public function edit($id)
 {
     $model = D('Menu');
     if (IS_POST) {
         if ($model->create()) {
             if ($model->updateMenu() !== false) {
                 $this->success('修改成功', cookie('forward'));
             } else {
                 $this->error('修改失败');
             }
         } else {
             $this->error(get_errors($model->getError()));
         }
     } else {
         //1.根据id获取数据表中的数据
         //获取所有的菜单
         $this->assign('all_menu', $model->getList(array('id,name,parent_id'), array(), true));
         //获取所有的权限
         //取出所有的权限
         $this->assign('all_permissions', D('Permission')->getList('id,name,parent_id', array(), true));
         //获取当前关联的权限
         $this->assign('perms', $model->getPermission($id, true));
         $row = $model->find($id);
         $this->assign('row', $row);
         $this->display();
     }
 }
开发者ID:kunx-edu,项目名称:tp1030,代码行数:30,代码来源:MenuController.class.php

示例10: logout

 public function logout()
 {
     session('user_status', NULL);
     cookie('token', NULL);
     cookie('username', NULL);
     cookie('userid', NULL);
 }
开发者ID:smilecc,项目名称:MakerLab,代码行数:7,代码来源:UserApi.class.php

示例11: logout

 public function logout()
 {
     cookie('suid', null);
     session('user', null);
     session('login', null);
     header('Location: ' . __SHOP__);
 }
开发者ID:u0mo5,项目名称:bookshop,代码行数:7,代码来源:UserAction.class.php

示例12: logout

 /**
  * 退出
  */
 public function logout()
 {
     session_regenerate_id();
     session(null);
     cookie(null);
     redirect(U('Login/index'));
 }
开发者ID:a3147972,项目名称:ThinkPHP-,代码行数:10,代码来源:LoginController.class.php

示例13: flow2

 public function flow2()
 {
     if (!is_login()) {
         cookie('__forward__', __SELF__);
         $this->error('请先登录', U('Member/login'));
         return;
     }
     if (IS_POST) {
         $order_model = D('OrderInfo');
         if ($order_model->addOrder()) {
             $this->redirect('flow3');
         } else {
             $this->error('下单失败,请稍后再试');
         }
     } else {
         //用户地址列表
         $this->assign('address_list', D('Address')->getAddList());
         //获取支付方式
         $this->assign('pay_list', D('Setting')->getPayList());
         //获取配送方式
         $this->assign('transport_list', D('Setting')->getTransportList());
         //取出购物车里面的内容
         $this->assign('car_list', D('ShoppingCar')->getCar());
         $this->display();
     }
 }
开发者ID:kunx-edu,项目名称:tp1030,代码行数:26,代码来源:ShoppingCarController.class.php

示例14: searchArticle

 /**
  * [searchArticle 搜索文章]
  * @Author   罗江涛
  * @DateTime 2016-03-07T17:03:47+0800
  */
 public function searchArticle()
 {
     // 接收关键字
     $keyword = I("keyword", 0);
     // 是否清除搜索历史
     $cleanSearchHistory = I("cleanSearchHistory", 0);
     // 清除搜索历史
     if ($cleanSearchHistory) {
         cookie("searchHistory", null);
     }
     // 获取搜索历史
     $searchHistory = cookie("searchHistory");
     if ($keyword) {
         // 如果有关键字则保存到搜索历史
         if (!in_array($keyword, $searchHistory) && $keyword != "{{ todo.logo }}") {
             $searchHistory[] = $keyword;
             //p($searchHistory);die;
             cookie("searchHistory", $searchHistory);
         }
     } else {
         // 没有关键字倒序搜索历史,并分配
         $searchHistory = array_reverse($searchHistory);
         $this->assign("searchHistory", $searchHistory);
     }
     $this->display();
 }
开发者ID:luojiangtao,项目名称:vcbeat_my,代码行数:31,代码来源:ArticleController.class.php

示例15: _initialize

 protected function _initialize()
 {
     $this->_name = CONTROLLER_NAME;
     if (isLogin()) {
         define('AID', isLogin());
         $this->uid = decrypt(cookie('admin_id'));
         $this->admin_name = decrypt(cookie('admin_name'));
         $this->assign('admin_name', $this->admin_name);
     } else {
         $this->redirect('Public/login');
         exit;
     }
     import('ORG.Util.Auth');
     //加载类库
     $auth = new Auth();
     if (in_array(isLogin(), C("ADMINISTRATOR"))) {
         return true;
     } else {
         if ($auth->check(CONTROLLER_NAME . '-*', isLogin())) {
             true;
         } elseif (!$auth->check(CONTROLLER_NAME . '-' . ACTION_NAME, isLogin())) {
             echo CONTROLLER_NAME . '-' . ACTION_NAME;
             die;
             $this->error('你没有权限');
         }
     }
 }
开发者ID:noikiy,项目名称:ypx,代码行数:27,代码来源:GlobalController.class.php


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