• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP cookie类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: request

 function request($type, $url, $get = [], $post = [])
 {
     $developer = cookie::developer();
     if ($developer) {
         $get['_mode'] = 'developer';
     }
     $request = ['method' => $type, 'protocol_version' => '1.1', 'header' => 'Connection: Close'];
     foreach ($post as $name => &$param) {
         if (is_array($param) and empty($param)) {
             $param = '_empty_array';
         }
     }
     if (!empty($post)) {
         $request['header'] .= "\r\nContent-type: application/x-www-form-urlencoded";
         $request['content'] = http_build_query($post);
     }
     $ctx = stream_context_create(['http' => $request]);
     $response = file_get_contents($this->endpoint . (empty($get) ? $url : $url . '?' . http_build_query($get)), false, $ctx);
     $object = json::decode($response, true);
     if (is_null($object)) {
         if ($developer) {
             var_dump($response);
             die;
         } else {
             throw new Exception("Error Processing Request", 1);
         }
     }
     $content = $object['content'];
     return (is_object($content) or is_array($content) and array_values($content) !== $content) ? (object) $content : $content;
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:30,代码来源:api.php


示例2: required

 static function required($perm_name, $item)
 {
     // Original code from the required function in modules/gallery/helpers/access.php.
     if (!access::can($perm_name, $item)) {
         if ($perm_name == "view") {
             // Treat as if the item didn't exist, don't leak any information.
             throw new Kohana_404_Exception();
         } else {
             access::forbidden();
         }
         // Begin rWatcher modifications.
         //   Throw a 404 error when a user attempts to access a protected item,
         //   unless the password has been provided, or the user is the item's owner.
     } elseif (module::get_var("albumpassword", "hideonly") == false) {
         $item_protected = ORM::factory("albumpassword_idcache")->where("item_id", "=", $item->id)->order_by("cache_id")->find_all();
         if (count($item_protected) > 0) {
             $existing_password = ORM::factory("items_albumpassword")->where("id", "=", $item_protected[0]->password_id)->find();
             if ($existing_password->loaded()) {
                 if (cookie::get("g3_albumpassword") != $existing_password->password && identity::active_user()->id != $item->owner_id && !identity::active_user()->admin) {
                     throw new Kohana_404_Exception();
                 }
             }
         }
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:25,代码来源:MY_access.php


示例3: show

 /**
  * Methode : page de détail d'une user
  */
 public function show($idQuete = false)
 {
     if (!$idQuete || !is_numeric($idQuete)) {
         return parent::redirect_erreur('quetes');
     }
     cookie::set('UserFilesPath', url::base() . '../images/quetes/' . $idQuete);
     cookie::set('UserFilesAbsolutePath', DOCROOT . '../images/quetes/' . $idQuete);
     if (!cookie::get('UserFilesPath')) {
         return url::redirect('quetes/show/' . $idQuete);
     }
     if (!($quete = $this->quete->select(array('id_quete' => $idQuete), 1))) {
         return parent::redirect_erreur('quetes');
     }
     if (!($module = Map_Model::instance()->select(array('module_map' => 'quete'), false))) {
         return url::redirect('regions?msg=' . urlencode(Kohana::lang('quete.no_module')));
     }
     $this->script = array('js/lib/jquery.validate', 'js/lib/jquery.facebox', 'js/quetes');
     $this->css = array('form', 'quete', 'facebox');
     $this->template->titre = array(Kohana::lang('quete.all_quetes') => 'quetes', Kohana::lang('quete.show_title', ucfirst(mb_strtolower($quete->title))) => NULL);
     $this->template->button = TRUE;
     $this->template->navigation = parent::navigation($idQuete, 'id_quete', 'quetes');
     $this->template->contenu = new View('formulaire/form');
     $this->template->contenu->action = 'quetes/save';
     $this->template->contenu->id = $idQuete;
     $this->template->contenu->formulaire = new View('quetes/show');
     $this->template->contenu->formulaire->row = $quete;
     $this->template->contenu->formulaire->module = $module;
     $this->template->contenu->formulaire->bots = Map_Model::instance()->select(array('module_map' => 'fight'), false);
     $this->template->contenu->formulaire->quete = $this->quete->select(array('id_quete !=' => $idQuete));
 }
开发者ID:ezioms,项目名称:RpgEditor,代码行数:33,代码来源:quetes.php


示例4: init

 function init() {
     $user='';
     $guest = front::get('guest');
     if($guest=='1'&&config::get('opguestadd')) {
         $user = 'Guest';
     }else {
         if(cookie::get('login_username') &&cookie::get('login_password')) {
             $user=new user();
             $user=$user->getrow(array('username'=>cookie::get('login_username')));
         }
     }
     if(cookie::get('login_username') &&cookie::get('login_password')) {
         $guestuser=new user();
         $guestuser=$guestuser->getrow(array('username'=>cookie::get('login_username')));
     }
     $this->view->guestuser = $guestuser;
     if(!$user &&front::$act != 'login'&&front::$act != 'register')  front::redirect(url::create('user/login'));
     $this->view->user=$user;
     $this->_user=new user;
     $this->table=front::get('manage');
     if($this->table <>'archive'&&$this->table <>'orders') exit('PAGE NOT FOUND!');
     $this->_table=new $this->table;
     $this->_table->getFields();
     $this->view->form=$this->_table->get_form();
     $this->_pagesize=config::get('manage_pagesize');
     $this->view->manage=$this->table;
     $this->view->primary_key=$this->_table->primary_key;
     if(!front::get('page')) front::$get['page']=1;
     $manage='table_'.$this->table;
     $this->manage=new $manage;
 }
开发者ID:jiangsuei8,项目名称:public_php_shl,代码行数:31,代码来源:manage_act.php


示例5: logout

 public function logout()
 {
     cookie::queue('uid', null, -1);
     cookie::queue('name', null, -1);
     cookie::queue('phone', null, -1);
     return redirect('/');
 }
开发者ID:LockGit,项目名称:dsk,代码行数:7,代码来源:AuthController.php


示例6: action_index

 public function action_index()
 {
     $this->template->content = View::factory('admin/projects/create')->bind('post', $post)->bind('errors', $errors)->bind('associates', $assoc);
     $assoc = DB::query(Database::SELECT, 'SELECT id, name FROM associates ORDER BY name')->execute()->as_array('id', 'name');
     // Add an option for "no associate"
     arr::unshift($assoc, 0, '- none -');
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('title', 'not_empty')->rule('title', 'regex', array('/^[\\pL\\pP\\s]{4,255}$/iu'))->rule('associate_id', 'not_empty')->rule('associate_id', 'in_array', array(array_keys($assoc)))->rule('completed', 'not_empty')->rule('completed', 'date')->rule('website', 'regex', array('#^https?://.+$#'));
     if ($post->check($errors)) {
         if (empty($post['associate_id'])) {
             // Make the associate NULL
             $post['associate_id'] = NULL;
             // Use only the title for the slug
             $post['slug'] = url::title($post['title']);
         } else {
             // Use the title with associate for the slug
             $post['slug'] = url::title($post['title']) . '/with/' . url::title($assoc[$post['associate_id']]);
         }
         if (empty($post['website'])) {
             // Make the website value NULL
             $post['website'] = NULL;
         }
         // Get the values of the array
         $values = $post->as_array();
         // Convert the completed date into a timestamp
         $values['completed'] = strtotime($values['completed']);
         $query = DB::query(Database::INSERT, 'INSERT INTO projects (title, associate_id, completed, website, slug) VALUES (:values)')->bind(':values', $values)->execute();
         // Set a cookie message
         cookie::set('message', 'Created new project with an ID of ' . $query);
         // Redirect back to the same page
         $this->request->redirect(url::site($this->request->uri));
     }
 }
开发者ID:pitchinvasion,项目名称:monobrow,代码行数:32,代码来源:projects.php


示例7: index_action

 function index_action() {
     if (front::post('submit')) {
         if (!front::post('ballot')) {
             front::alert(lang('Please_select_vote'));
             return false;
         }
         if (config::get('checkip')) {
             $time=cookie::get('vttime');
             if (time() -$time <config::get('timer') * 60) {
                 front::alert(lang('You_have_voted'));
                 return false;
             }
         }
         $bid=front::$post['bid'];
         if (is_array(front::$post['ballot'])) {
             $ids=implode(',',front::$post['ballot']);
         }
         else {
             $ids=front::$post['ballot'];
         }
         if(preg_match('/(select|union|and|\'|"|\))/i',$ids)){
         	exit('非法参数');
         }
         if(preg_match('/(select|union|and|\'|"|\))/i',$bid)){
         	exit('非法参数');
         }
         $where="id in($ids)";
         $data='num=num+1';
         $option=new option();
         $option->rec_update($data,$where);
         $this->_table->rec_update($data,$bid);
         cookie::set('vttime',time(),time() +3600 * 24);
         front::alert(lang('Successful_vote'));
     }
 }
开发者ID:jiangsuei8,项目名称:public_php_shl,代码行数:35,代码来源:ballot_act.php


示例8: show

 /**
  * Methode : page de détail d'un article
  */
 public function show($idActualite = FALSE)
 {
     if (!$idActualite || !is_numeric($idActualite)) {
         return parent::redirect_erreur('articles');
     }
     cookie::set('UserFilesPath', url::base() . '../images/articles/' . $idActualite);
     cookie::set('UserFilesAbsolutePath', DOCROOT . '../images/articles/' . $idActualite);
     if (!cookie::get('UserFilesPath')) {
         return url::redirect('articles/show/' . $idActualite);
     }
     if (!($actualite = $this->acticles->select(array('id_article' => $idActualite), TRUE))) {
         return parent::redirect_erreur('articles');
     }
     $actualiteCategories = $this->acticles->selectListeCategories();
     $this->script = array('js/lib/jquery.validate', 'js/articles');
     $this->css = array('form', 'article');
     $this->template->titre = array(Kohana::lang('article.all_article') => 'articles', $actualite->title => NULL);
     $this->template->button = TRUE;
     $this->template->navigation = $this->acticles->navigation($idActualite, 'id_article', 'articles');
     $this->template->navigationURL = 'articles/show';
     $this->template->contenu = new View('formulaire/form');
     $this->template->contenu->action = 'articles/save';
     $this->template->contenu->id = $idActualite;
     $this->template->contenu->formulaire = new View('articles/show');
     $this->template->contenu->formulaire->row = $actualite;
     $this->template->contenu->formulaire->actualiteCategories = $actualiteCategories;
     $this->template->contenu->formulaire->regions = Region_Model::instance()->listing_parent();
 }
开发者ID:ezioms,项目名称:RpgEditor,代码行数:31,代码来源:articles.php


示例9: __construct

 public function __construct(Request $request)
 {
     // Delete the authorization
     cookie::delete('authorized');
     // Redirect to the login page
     $request->redirect(url::site($request->uri(array('controller' => NULL))));
     // Do not call anything here, redirect has already halted execution.
 }
开发者ID:pitchinvasion,项目名称:monobrow,代码行数:8,代码来源:logout.php


示例10: logout

 /**
  * Log a user out and remove any auto-login cookies.
  *
  * @param   boolean  completely destroy the session
  * @return  boolean
  */
 public function logout($destroy)
 {
     if (cookie::get('authautologin')) {
         // Delete the autologin cookie to prevent re-login
         cookie::delete('authautologin');
     }
     return parent::logout($destroy);
 }
开发者ID:plusjade,项目名称:plusjade,代码行数:14,代码来源:ORM.php


示例11: __construct

 function __construct()
 {
     // Check and see if this is being run from the command line
     define('IS_CLI', 'cli' == PHP_SAPI);
     parent::__construct();
     Footsteps::step();
     $this->template->title = ucwords(router::$method);
     $this->session = Session::instance();
     $this->template->robots = '';
     if (router::$controller != 'page') {
         if (!Auth::instance()->logged_in() and !cookie::get('qaargh_visited', false, true)) {
             $this->session->set_flash('notice', 'It looks like this is your first time here. Click "home" to find out more about Q-Aargh!');
             cookie::set(array('name' => 'qaargh_visited', 'value' => true, 'expire' => 31536000));
         }
     } else {
         cookie::set(array('name' => 'qaargh_visited', 'value' => true, 'expire' => 31536000));
     }
     try {
         $this->template->view = new View(strtolower(router::$controller . '/' . router::$method));
     } catch (Exception $e) {
         $this->template->view = new View('error/missing_view');
     }
     if (Auth::instance()->logged_in()) {
         $this->template->menu = new View('menu/logged_in');
     } else {
         $this->template->menu = new View('menu/logged_out');
     }
     // Handle built-in authorization
     if (array_key_exists(router::$method, $this->auth_required)) {
         // If it's in the array, you must at least be logged in.
         if (!Auth::instance()->logged_in()) {
             $this->session->set_flash('error', Kohana::lang('general.login_required'));
             url::redirect("/user/login");
         }
         $authorized = false;
         // If it's *, then being logged in is enough
         if ('*' == $this->auth_required[router::$method]) {
             $authorized = true;
         } else {
             if (is_array($this->auth_required[router::$method])) {
                 foreach ($this->auth_required[router::$method] as $right) {
                     if (Auth::instance()->logged_in($right)) {
                         $authorized = false;
                         break;
                     }
                 }
             } else {
                 if (Auth::instance()->logged_in($this->auth_required[router::$method])) {
                     $authorized = false;
                 }
             }
         }
         if (!$authorized) {
             $this->session->set_flash('error', Kohana::lang('general.insufficient_privileges'));
             url::redirect("/user");
         }
     }
 }
开发者ID:jmhobbs,项目名称:q-aargh,代码行数:58,代码来源:application.php


示例12: __construct

 function __construct()
 {
     $this->session = session::getInstance();
     $this->post = post::getInstance();
     $this->get = get::getInstance();
     $this->http = http::getInstance();
     $this->file = file::getInstance();
     $this->cookie = cookie::getInstance();
 }
开发者ID:jin123456bat,项目名称:Framework2.0,代码行数:9,代码来源:base.php


示例13: readCart

 /**
  * 显示购物车内容
  *
  * @return array
  *
  * @example 返回数据类型为:array(array(商品ID, 商品名称, 商品数量, 商品单价, array(其实信息)), array(...));
  */
 public function readCart()
 {
     // 从购物车cookie中读取数据
     $data = cookie::get($this->cartName);
     if (!$data) {
         return false;
     }
     return $data;
 }
开发者ID:marslabtron,项目名称:waimai,代码行数:16,代码来源:CartCookie.class.php


示例14: index

 function index()
 {
     //判断用户是否是已经登录状态
     $data = role::get_manager();
     if ($data['id'] > 0) {
         $data['success'] = 'true';
         $data['msg'] = 1;
     } else {
         $data['success'] = 'false';
         $data['msg'] = 1;
     }
     $username = $this->input->post('username');
     $password = $this->input->post('password');
     $secode = $this->input->post('secode');
     $remember = $this->input->post('remember');
     $data['success'] = 'false';
     //验证登录
     $manager = role::log_in($username, $password);
     if (isset($manager['username'])) {
         //判断普通账号的状态、权限
         if (!role::is_root($manager['username'])) {
             if ($manager['active'] != 1) {
                 ulog::login($manager['id'], 1);
                 $data['msg'] = Kohana::lang('o_global.account_was_locked');
             }
             $actions = role::manager_actions($manager['id'], TRUE);
             if (count($actions) < 1) {
                 ulog::login($manager['id'], 2);
                 $data['msg'] = Kohana::lang('o_global.account_permission_enough');
             }
         }
         //是否记录用户名
         if ($remember == 1) {
             cookie::set('opococ_username', $username);
         } else {
             cookie::delete('opococ_username');
         }
         //清除记录登录错误记录
         //Session::instance()->delete('login_error_count');
         //记入SESSION
         role::set_manager_session($manager);
         //记录日志
         ulog::login($manager['id']);
         $data['success'] = 'true';
         $data['msg'] = 1;
         /*if(empty($request_url))
         		{
         			remind::set(Kohana::lang('o_global.login_success'), '/index', 'success');
         		}
                    else
                    {
         			$request_url = url::base() . urldecode($request_url);
         			remind::set(Kohana::lang('o_global.login_success'), $request_url, 'success');
         		}*/
     }
     die(json_encode($data));
 }
开发者ID:RenzcPHP,项目名称:3dproduct,代码行数:57,代码来源:user_login.php


示例15: clear

 static function clear($key = null)
 {
     $key = cookie::close_key($key, false);
     if ($key === cookie::close_key(null, false)) {
         session_unset();
     } else {
         unset($_SESSION[$key]);
     }
 }
开发者ID:art-youth,项目名称:framework,代码行数:9,代码来源:session.php


示例16: __construct

 public function __construct()
 {
     $this->registry = registry::getInstance();
     $this->path = $this->registry["path"];
     $this->html = html::getInstance();
     $this->session = session::getInstance();
     $this->cookie = cookie::getInstance();
     $this->ajax = new ajax();
     $this->l10n = l10n::getInstance();
 }
开发者ID:vyk2rr,项目名称:FlavorPHP-2.0,代码行数:10,代码来源:views.class.php


示例17: __construct

 /**
  * 构造函数
  */
 public function __construct()
 {
     $cookie = cookie::get(COOKIE_KEY);
     if (!$cookie) {
         redirect('./');
         return;
     }
     view::assign('setting', madmin::get_setting());
     view::assign('now', time());
 }
开发者ID:luozhanhong,项目名称:share,代码行数:13,代码来源:admin.php


示例18: kill

 protected static function kill()
 {
     self::$user = null;
     // overwrite the token
     $token = str::random();
     // the cookie is valid for 24 hours
     cookie::set('authFrontend', $token, 60 * 60 * 24);
     // restart the session
     s::restart();
 }
开发者ID:scheibome,项目名称:kirbycms-extensions,代码行数:10,代码来源:auth.php


示例19: getReferral

 public function getReferral()
 {
     $chkCookie = cookie::exists(COOKIE_SPONSOR_NAME);
     if ($chkCookie) {
         $referral = cookie::get(COOKIE_SPONSOR_NAME);
     } else {
         $referral = NULL;
     }
     return $referral;
 }
开发者ID:kronxblue,项目名称:1stg,代码行数:10,代码来源:supp_model.php


示例20: delete

 /**
  * Nullify and unset a cookie.
  *
  * @param   string   cookie name
  * @param   string   URL path
  * @param   string   URL domain
  * @return  boolean
  */
 public static function delete($name, $path = NULL, $domain = NULL)
 {
     if (!isset($_COOKIE[$name])) {
         return FALSE;
     }
     // Delete the cookie from globals
     unset($_COOKIE[$name]);
     // Sets the cookie value to an empty string, and the expiration to 24 hours ago
     return cookie::set($name, '', -86400, $path, $domain, FALSE, FALSE);
 }
开发者ID:darkcolonist,项目名称:kohana234-doctrine115,代码行数:18,代码来源:cookie.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP core类代码示例发布时间:2022-05-23
下一篇:
PHP convert类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap