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

PHP set_cookie函数代码示例

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

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



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

示例1: submit

 function submit()
 {
     $data = array("css_filename" => "login", "title" => "管理后台登录", "message" => "", "messageclass" => "");
     $this->load->view("admin/Login", $data);
     if (!$_POST) {
         redirect("cp/login");
     }
     $username = $_POST["username"];
     $password = $_POST["password"];
     if ($username == "") {
         $this->_showMessage("您还未输入用户名。", 0);
         return;
     }
     if ($password == "") {
         $this->_showMessage("您的密码还未输入。", 0);
         return;
     }
     $this->load->model("Users");
     //MD5加密码
     $password = dohash($password, 'md5');
     $result = $this->Users->CheckLogin($username, $password);
     if ($result == 0) {
         $this->_showMessage("对不起,您的密码不正确,请重新输入。", 0);
     } else {
         set_cookie("username", $username, "3600", "", "/");
         set_cookie("password", $password, "3600", "", "/");
         redirect("");
     }
 }
开发者ID:huacnlee,项目名称:booklib,代码行数:29,代码来源:login.php


示例2: validate

 function validate()
 {
     $this->db->where('nic', $this->input->post('username'));
     $this->db->where('pass', md5($this->input->post('password')));
     //A checkbox to remember me after login
     $check_box = $this->input->post('rember_me');
     $query = $this->db->get('user');
     if ($query->num_rows == 1) {
         //Setup session
         foreach ($query->result() as $row) {
             //$user_level = $row->user_level;
             $username = $row->nic;
             $password = $row->pass;
             $id = $row->id;
             $first_name = $row->first;
             $last_name = $row->last;
             $data = array('username' => $username, 'id' => $id, 'name' => $name, 'user_level' => 1, 'is_logged_in' => true);
             $this->session->set_userdata($data);
         }
         //if statement for remember me
         if ($check_box == "accept") {
             $value = array('id' => $id, 'username' => $username);
             $value = serialize($value);
             $cookie = array('name' => 'loginuser', 'value' => $value, 'expire' => '2410000', 'domain' => 'mysocialnetwork.es', 'path' => '/', 'prefix' => '', 'secure' => false);
             set_cookie($cookie);
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:asbag,项目名称:codeigniter,代码行数:31,代码来源:login_model.php


示例3: login

 public function login()
 {
     if ($this->auth != NULL) {
         $this->cm_string->php_redirect("backend");
     }
     if ($this->db->count_all_results('cm_user') == 0) {
         $this->cm_string->php_redirect("backend/auth/create_manager");
     }
     $data['seo']['title'] = 'Color ME Admin';
     $data['seo']['keywords'] = '';
     $data['seo']['description'] = 'Login System of Color ME';
     if ($this->input->post('login')) {
         $post_data = $this->input->post();
         $data['post_data']['username'] = $post_data['username'];
         $data['post_data']['password'] = $post_data['password'];
         $this->form_validation->set_rules('username', 'Username', 'trim|required|regex_match[/^([a-z0-9_])+$/i]|callback__username_check');
         $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[8]|callback__password_check[' . $post_data['username'] . ']');
         if ($this->form_validation->run() == TRUE) {
             $user = $this->db->select('username,password,salt')->where(array('username' => $post_data['username']))->from('user')->get()->row_array();
             set_cookie(md5(base_url()) . 'user_logged', $this->cm_string->encrypt_cookie(json_encode($user)), time() + 7 * 24 * 3600);
             $data = array('logined' => gmdate('Y-m-d H:i:s', time() + 7 * 3600), 'ip_logging' => $_SERVER['SERVER_ADDR']);
             $this->db->where(array('username' => $post_data['username']))->update('user', $data);
             //                $this->cm_string->js_redirect('Login Success', base_url('backend/Auth/login'));
             $this->cm_string->php_redirect("backend/Auth/login");
         }
     }
     $data['template'] = 'backend/auth/login';
     $this->load->view('backend/layout/login', isset($data) ? $data : NULL);
 }
开发者ID:Kaelcao,项目名称:colorme,代码行数:29,代码来源:Auth.php


示例4: center

 function center()
 {
     $file = $this->uri->rsegment(3, '');
     $url = 'user/user_main/index';
     if ($file == 'inbox') {
         $url = 'user/message/inbox';
     }
     $rs = $this->comm->find("member", array('username' => $this->username, 'password' => $this->password), "", "userid,username,password,loginip,logintime,logintimes");
     if ($rs) {
         $logintimes = intval($rs['logintimes']) + 1;
         $udata = array('loginip' => $_SERVER['REMOTE_ADDR'], 'logintime' => $_SERVER['REQUEST_TIME'], 'lastip' => $rs['loginip'], 'lasttime' => $rs['logintime'], 'logintimes' => $logintimes);
         $this->comm->update("member", array("userid" => $rs['userid']), $udata);
         $this->load->library('encrypt');
         $hash_1 = $this->encrypt->sha1($rs['username'] . time());
         $hash_2 = $this->encrypt->sha1($rs['password'] . time());
         $username = $this->encrypt->encode($rs['username'], $hash_1);
         $password = $this->encrypt->encode($rs['password'], $hash_2);
         $this->load->helper('cookie');
         $site = $this->config->item('site');
         set_cookie('username', $username, 3600, ".{$site['site_url']}");
         set_cookie('password', $password, 3600, ".{$site['site_url']}");
         set_cookie('hash_1', $hash_1, 3600, ".{$site['site_url']}");
         set_cookie('hash_2', $hash_2, 3600, ".{$site['site_url']}");
     }
     redirect(main_url(site_url($url)));
 }
开发者ID:perfectss,项目名称:yunlian,代码行数:26,代码来源:Main.php


示例5: login

 /**
  * login
  * 
  * Phương thức đăng nhập
  * 
  * @param type $arrOutput
  * @param type $arrInput
  * @param type $strRedirect
  * @param type $strMode
  */
 function login(&$arrOutput = array(), $arrInput = array(), $strRedirect = '', $strMode = '')
 {
     // get the CI object
     $CI =& get_instance();
     $CI->load->helper('cookie');
     $CI->load->library('session');
     $CI->load->model('common_model');
     if ($strMode == 'account') {
         $CI->db->where('username', $arrInput['username']);
         $CI->db->where('password', $arrInput['password']);
         $CI->db->where('status', 1);
         $arrUserInfo = $CI->db->get('users')->row_array();
         if ($arrUserInfo != null && count($arrUserInfo) > 0) {
             if ($this->checkAllowLogin($arrUserInfo['role_id'])) {
                 if ($arrInput['remember'] == 1) {
                     set_cookie('user_id', $arrUserInfo['id'], 86500);
                 } else {
                     $CI->session->set_userdata('user_id', $arrUserInfo['id']);
                 }
                 // Update last login
                 $CI->db->where('id', $arrUserInfo['id']);
                 $CI->db->update('users', array('lastlogin' => getCurrentDt()));
                 // Redirect to admin panel
                 redirect($strRedirect);
             } else {
                 $arrOutput['errLogin'] = LTV0055;
             }
         } else {
             $arrOutput['errLogin'] = LTV0001;
         }
     }
 }
开发者ID:thaivuong90,项目名称:ban_hang,代码行数:42,代码来源:MY_login.php


示例6: loginOut

 static function loginOut()
 {
     $user = self::getLoginUser();
     $userID = MyDes::share()->encode($user->id, DES_KEY);
     self::delLoginInfo($userID);
     set_cookie(getC('LOGIN_KEY'), 0, -1);
 }
开发者ID:lingPro,项目名称:zj_web_demo,代码行数:7,代码来源:LoginService.class.php


示例7: loginFromDatabase

function loginFromDatabase($_uid)
{
    global $mysql;
    $user = $mysql->query('select * from users where ID=' . $_uid)->fetch();
    if (!$user) {
        return -1;
    }
    set_cookie($user['cookie']);
    if (isset($user['bduss'])) {
        //删除数据库里的无用列
        $mysql->query('ALTER TABLE `users` DROP `bduss`');
    }
    global $cookie_jar, $bduss;
    if (!isset($cookie_jar['BDUSS'])) {
        return false;
    }
    $bduss = $cookie_jar['BDUSS'];
    //原本想把bdstoken存进数据库,想到需要检验cookie是否合法,还是改成动态获取
    global $bdstoken;
    $bdstoken = validateCookieAndGetBdstoken();
    if (!$bdstoken) {
        $bduss = false;
        return false;
    }
    global $uid, $username, $md5;
    $uid = $_uid;
    $username = $user['username'];
    $md5 = $user['newmd5'] === '' ? false : $user['newmd5'];
    return true;
}
开发者ID:NijiharaTsubasa,项目名称:BaiduPanAutoReshare,代码行数:30,代码来源:common.php


示例8: setFlow

 function setFlow()
 {
     $this->load->database();
     //存入cookie中
     $this->load->helper('cookie');
     $yk_id = get_cookie('id');
     //获取游客id
     set_cookie('flow', '100M');
     $count = $this->db->where('id', $yk_id)->from('user_session')->count_all_results();
     //插入之前先查查游客表该游客是否被记录了
     $session_data = array('id' => $yk_id, 'flow' => '100M');
     if ($count > 0) {
         //游客已经存入表中,只是更新
         unset($session_data['id']);
         $this->db->where('id', $yk_id)->update('user_session', $session_data);
     } else {
         $this->db->insert('user_session', $session_data);
     }
     $username = $this->session->userdata['username'];
     if ($username) {
         //如果用户已经注册,则还要存入用户表
         $this->db->where('username', $username)->update('userinfo', array('flow' => '100M'));
     }
     echo 'success';
 }
开发者ID:cygjs100crew,项目名称:cygjs_fr,代码行数:25,代码来源:Welcome.php


示例9: doLogin

 public function doLogin($uid)
 {
     //登录要写cookie,内容包含uid和在线id
     $onlineId = $this->save_online_info($uid);
     $cookieCont = $this->encode_cookie($uid, $onlineId);
     set_cookie($this->cookieName, $cookieCont, $this->CI->config->item('login_expire'));
 }
开发者ID:jiangshanmeta,项目名称:jiangshanmeta.github.io,代码行数:7,代码来源:Login.php


示例10: login

 public function login()
 {
     $this->load->model('user_model', 'User');
     $this->load->model('application_model', 'Application');
     if (get_cookie("eventribe-remember-token") != "") {
         $login = $this->User->get_user_from_token(get_cookie("eventribe-remember-token"));
         $this->session->set_userdata("user", $login);
         redirect(base_url() . 'router/org_picker/' . $login);
     } else {
         $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[250]');
         $this->form_validation->set_rules('password', 'Password', 'required|min_length[5]|max_length[250]');
         //run validation
         if ($this->form_validation->run() == FALSE) {
             $this->session->set_flashdata('errors', validation_errors());
             redirect(base_url());
         } else {
             $login = $this->User->login($this->input->post('username'), $this->input->post('password'));
             if ($login != "" && $login != "invalid login parameters") {
                 $this->session->set_userdata("user", $login);
                 $this->session->set_userdata("username", $this->input->post("username"));
                 $this->session->set_userdata("password", $this->input->post("password"));
                 if ($this->input->post("remember") == 1) {
                     $token = $this->User->set_remember_me($this->input->post("username"), $this->input->post("password"));
                     $expire = time() + 2678400;
                     $cookie = array('name' => 'eventribe-remember-token', 'value' => $token, 'expire' => $expire, 'secure' => TRUE);
                     set_cookie($cookie);
                 }
                 redirect(base_url() . 'router/org_picker/' . $login);
             } else {
                 $this->session->set_flashdata('errors', $login);
                 redirect(base_url());
             }
         }
     }
 }
开发者ID:Omar-Faramawi,项目名称:codeigniter-eventrib-project,代码行数:35,代码来源:router.php


示例11: logout

 public function logout()
 {
     $this->load->helper('cookie');
     set_cookie('menu_url', '', time() - 3600);
     $this->session->sess_destroy();
     successRedirct('backend/user/login', "退出成功!");
 }
开发者ID:zhupengfei365,项目名称:backend.hc.com,代码行数:7,代码来源:User.php


示例12: space_count

 public function space_count()
 {
     $uid = (int) $this->input->get('uid');
     if ($this->uid && $uid && $this->uid != $uid) {
         // 记录访客信息
         $name = 'space-count-' . $this->uid . '-' . $uid;
         if (get_cookie($name)) {
             // 缓存期
         } else {
             // 查询今天是否访问过
             if ($this->db->where('uid', $this->uid)->where('spaceid', $uid)->where('DATEDIFF(from_unixtime(inputtime),now())=0')->count_all_results('space_access')) {
                 $this->db->where('uid', $this->uid)->where('spaceid', $uid)->update('space_access', array('inputtime' => SYS_TIME));
             } else {
                 $this->db->insert('space_access', array('uid' => $this->uid, 'spaceid' => $uid, 'content' => '', 'username' => $this->member['username'], 'inputtime' => SYS_TIME));
             }
             set_cookie($name, SYSTIME, 300);
             // 5分钟统计一次
         }
     }
     // 验证空间权限
     if ($this->_space_show($uid)) {
         $callback = isset($_GET['callback']) ? $_GET['callback'] : 'callback';
         exit($callback . '(' . json_encode(array('url' => dr_member_url('api/access', array('uid' => $uid)))) . ')');
     }
     exit('');
 }
开发者ID:Thebeautifullife,项目名称:yichunchengguan,代码行数:26,代码来源:Api.php


示例13: skins

 public function skins()
 {
     $skin = $this->input->get_post('skin', TRUE);
     $skin = $skin ? $skin : 'green';
     set_cookie('skin', $skin, 120000);
     die('{"status":200,"msg":"success"}');
 }
开发者ID:Neo-Luo,项目名称:amc,代码行数:7,代码来源:settings.php


示例14: login

 public function login()
 {
     $username = $this->input->post('username');
     $password = $this->input->post('password');
     $remember_check = $this->input->post('remember_check');
     if (isset($remember_check)) {
         set_cookie('ck_username', $username, time() + 60);
         set_cookie('ck_password', $password, time() + 60);
         set_cookie('ck_remember', $remember_check, time() + 60);
     } else {
         delete_cookie('ck_username');
         delete_cookie('ck_password');
         delete_cookie('ck_remember');
     }
     $salt = '$2a$04$123456789123456789123$';
     $hashed_password = crypt($password, $salt);
     $where_arr = array('admin_name' => $username, 'admin_pass' => $hashed_password);
     $query = $this->db->get_where("tbl_admin", $where_arr);
     $row = $query->row_array();
     //คิวรี่ข้อมูลมาแสดงแค่รายการเดียว
     if (isset($row)) {
         $newdata = array('ses_admin_id' => $row['admin_id'], 'ses_admin_name' => $row['admin_name']);
         $this->session->set_userdata($newdata);
         // อัพเดทข้อมูลการล็อกอินของ admin เช่น ล็อกอินล่าสุด
         $update_data = array('admin_lastlogin	' => date("Y-m-d H:i:s"));
         $this->db->update('tbl_admin', $update_data, array('admin_id' => $row['admin_id']));
     }
     redirect('admin');
     // ไปหน้า admin
 }
开发者ID:phannack,项目名称:Learn-CodeIgniter,代码行数:30,代码来源:Admin.php


示例15: mobile_detect

 function mobile_detect()
 {
     if (!INSTALL_MODULE_DONE) {
         return false;
     }
     $CI =& get_instance();
     $CI->load->helper('cookie');
     $mobile_detect = filter_input(INPUT_GET, 'mobile_detect');
     if (empty($mobile_detect)) {
         $mobile_detect = filter_input(INPUT_COOKIE, 'mobile_detect');
     } elseif ('denied' === $mobile_detect) {
         // Back from the mobapp
         set_cookie(array('name' => 'mobile_detect', 'value' => 'denied', 'expire' => time() + '86500', 'domain' => COOKIE_SITE_SERVER, 'path' => '/' . SITE_SUBFOLDER));
         return false;
     }
     if ('denied' === $mobile_detect || !$CI->pg_module->is_module_installed('mobile') || $CI->router->is_api_class || !$CI->pg_module->get_module_config('mobile', 'use_mobile_detect')) {
         return false;
     } else {
         $CI->load->library('mobile_detect');
         if ($CI->mobile_detect->isMobile()) {
             set_cookie(array('name' => 'mobile_detect', 'value' => 'ask', 'expire' => time() + '86500', 'domain' => COOKIE_SITE_SERVER, 'path' => '/' . SITE_SUBFOLDER));
             redirect($CI->pg_module->get_module_config('mobile', 'app_url') . '/#!/redirect');
         }
         return true;
     }
 }
开发者ID:Calit2-UCI,项目名称:IoT_Map,代码行数:26,代码来源:post_controller_constructor-mobile_detect.php


示例16: dsession

 function dsession()
 {
     $this->obj = new Memcache();
     include DT_ROOT . '/file/config/memcache.inc.php';
     $num = count($MemServer);
     if ($num == 1) {
         $key = 0;
     } else {
         $key = get_cookie('memcache');
         if ($key == -1) {
             $key = 0;
         } else {
             if (!isset($MemServer[$key])) {
                 $key = array_rand($MemServer);
                 set_cookie('memcache', $key ? $key : -1);
             }
         }
     }
     $this->obj->connect($MemServer[$key]['host'], $MemServer[$key]['port'], 2);
     if (DT_DOMAIN) {
         @ini_set('session.cookie_domain', '.' . DT_DOMAIN);
     }
     session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc'));
     session_cache_limiter('private, must-revalidate');
     session_start();
     header("cache-control: private");
 }
开发者ID:hcd2008,项目名称:destoon,代码行数:27,代码来源:session_memcache.class.php


示例17: sCookie

 public function sCookie($usn, $accountID)
 {
     $this->load->helper('cookie');
     $cookie = array('name' => 'MemberInfo', 'value' => json_encode(array('accountID' => $accountID, 'usn' => $usn)), 'expire' => '86500', 'prefix' => 'codingclub_', 'domain' => CKDOMAIN);
     set_cookie($cookie);
     return;
 }
开发者ID:jazzwave1,项目名称:CC,代码行数:7,代码来源:Membership_model.php


示例18: login

 /**
  * Login method
  * @functionality will check username and password to make user logged
  * */
 public function login()
 {
     if ($this->data['auth']) {
         redirect(base_url($this->data['lang']));
     }
     $data = ['email' => $this->input->post('email'), 'password' => md5($this->input->post('password'))];
     $user = $this->user_model->login($data)[0];
     if (!$user) {
         $this->session->set_flashdata('error', 'Invalid email address or password');
         redirect(base_url($this->data['lang']));
     } else {
         if ($user->email_verified != 1) {
             $this->load->helper('cookie');
             set_cookie('user_id', $user->id, '300');
             set_cookie('user_email', $user->email, '300');
             $this->session->set_flashdata('error', 'Sorry your email address is not verified.
                                                    Please go to your inbox messages and follow to instruction or click
                                                    <a href="' . $this->data['lang'] . '/action/register/registered">Send again</a>');
             redirect(base_url($this->data['lang']));
         } else {
             $user_info = $this->user_model->get_where(['user_id' => $user->id], '*', 'user_info')[0];
             $this->session->set_userdata(['user_info' => $user_info, 'user' => $user, 'is_logged_in' => true]);
             $this->user_model->set_table('users');
             redirect(base_url($this->data['lang'] . '/user/profile'));
         }
     }
 }
开发者ID:varyan,项目名称:transinfo,代码行数:31,代码来源:Client_action.php


示例19: index

 /**
  * 执行任务和队列
  */
 public function index()
 {
     // 第三方执行队列时,非命令行不执行
     if (SYS_CRON_QUEUE && !(PHP_SAPI === 'cli' || defined('STDIN'))) {
         exit;
     }
     // 自动更新模块缓存(3小时一次)
     $file = FCPATH . 'cache/auto.log';
     $auto = is_file($file) ? (int) file_get_contents($file) : 0;
     if (!$auto || $auto <= SYS_TIME - 10800) {
         $this->clear_cache('module');
         file_put_contents($file, SYS_TIME);
     }
     // 未到发送时间
     if (get_cookie('cron')) {
         exit;
     }
     // 一次执行的任务数量
     $pernum = defined('SYS_CRON_NUMS') && SYS_CRON_NUMS ? SYS_CRON_NUMS : 10;
     // 用户每多少秒调用本程序
     set_cookie('cron', 1, SYS_CRON_TIME);
     // 查询所有队列记录
     $queue = $this->db->order_by('status ASC,id ASC')->limit($pernum)->get('cron_queue')->result_array();
     if (!$queue) {
         // 所有任务执行完毕
         $this->db->query('TRUNCATE `' . $this->db->dbprefix('cron_queue') . '`');
         exit;
     }
     foreach ($queue as $data) {
         $this->cron_model->execute($data);
     }
     // 本次任务执行完毕
     exit;
 }
开发者ID:xxjuan,项目名称:php-coffee,代码行数:37,代码来源:Cron.php


示例20: ajax

 public function ajax()
 {
     $data = $this->input->post('data', TRUE);
     $uid = $this->member_model->admin_login($data['username'], $data['password']);
     if ($uid > 0) {
         set_cookie('finecms-admin-login', $data['username'], 999999);
         exit(dr_json(1, 1, 1));
     }
     if ($uid == -1) {
         $error = lang('043');
         exit(dr_json(0, $error, 'username'));
     } elseif ($uid == -2) {
         $error = lang('044');
         exit(dr_json(0, $error, 'password'));
     } elseif ($uid == -3) {
         $error = lang('045');
         exit(dr_json(0, $error, 'username'));
     } elseif ($uid == -4) {
         $error = lang('046');
         exit(dr_json(0, $error, 'username'));
     } else {
         $error = lang('047');
         exit(dr_json(0, $error, 'username'));
     }
 }
开发者ID:Thebeautifullife,项目名称:yichunchengguan,代码行数:25,代码来源:Login.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP set_coursemodule_groupmode函数代码示例发布时间:2022-05-15
下一篇:
PHP set_controller函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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