本文整理汇总了PHP中setCookie函数的典型用法代码示例。如果您正苦于以下问题:PHP setCookie函数的具体用法?PHP setCookie怎么用?PHP setCookie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setCookie函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
/**
* โหลด GCMS เพื่อแสดงผลหน้าเว็บไซต์
*/
public function run()
{
/**
* inint session
*/
session_start();
if (!ob_get_status()) {
if (extension_loaded('zlib') && !ini_get('zlib.output_compression')) {
// เปิดใช้งานการบีบอัดหน้าเว็บไซต์
ob_start('ob_gzhandler');
} else {
ob_start();
}
}
/**
* โหลด GCMS
*/
$this->inint();
/**
* save variable
*/
setCookie('gcms_language', LANGUAGE, time() + 3600 * 24 * 365);
/**
* create Router
*/
self::createClass('Core\\Router');
/**
* return current instance
*/
return self::$instance;
}
开发者ID:boyatomic32,项目名称:movie,代码行数:34,代码来源:gcms.php
示例2: send
protected function send()
{
if (!headers_sent()) {
$code = $this->getStatusCode();
$version = $this->getProtocolVersion();
if ($code !== 200 || $version !== '1.1') {
header(sprintf('HTTP/%s %d %s', $version, $code, $this->getReasonPhrase()));
}
foreach ($this->headers as $key => $value) {
$key = ucwords(strtolower($key), '-');
if (is_array($value)) {
$value = implode(',', $value);
}
header(sprintf('%s: %s', $key, $value));
}
foreach ($this->cookies as $cookie) {
list($name, $value, $expire, $path, $domain, $secure, $httponly) = $cookie;
setCookie($name, $value, $expire, $path, $domain, $secure, $httponly);
}
}
$body = $this->getBody();
if ($body instanceof IteratorStream) {
foreach ($body->iterator() as $string) {
echo $string;
}
} else {
echo (string) $body;
}
}
开发者ID:locphp,项目名称:rsf,代码行数:29,代码来源:Response.php
示例3: reset
public function reset()
{
global $clientRoot;
setCookie("colltaxa", "", time() - 3600, $clientRoot ? $clientRoot : '/');
setCookie("collsearch", "", time() - 3600, $clientRoot ? $clientRoot : '/');
setCookie("collvars", "", time() - 3600, $clientRoot ? $clientRoot : '/');
$this->reset = 1;
if (array_key_exists("db", $this->searchTermsArr) || array_key_exists("oic", $this->searchTermsArr)) {
//reset all other search terms except maintain the db terms
$dbsTemp = "";
if (array_key_exists("db", $this->searchTermsArr)) {
$dbsTemp = $this->searchTermsArr["db"];
}
$clidTemp = "";
if (array_key_exists("clid", $this->searchTermsArr)) {
$clidTemp = $this->searchTermsArr["clid"];
}
unset($this->searchTermsArr);
if ($dbsTemp) {
$this->searchTermsArr["db"] = $dbsTemp;
}
if ($clidTemp) {
$this->searchTermsArr["clid"] = $clidTemp;
}
}
}
开发者ID:Symbiota,项目名称:Symbiota,代码行数:26,代码来源:AgentManager.php
示例4: logUserOut
function logUserOut()
{
setSessionVar('login', false);
setCookie('keep_log', '0', time() - 3600, '/', $_SERVER['HTTP_HOST'], false, true);
unset($_COOKIE['keep_log']);
quitSession();
}
开发者ID:extendgears,项目名称:php-components,代码行数:7,代码来源:log.php
示例5: catchEvent
public function catchEvent($moduleGroup, $moduleName, $event, $parameters)
{
global $session;
global $parametersMod;
if (!isset($session) || $session->loggedIn()) {
//in admin.php $session is not defined on time of this event.
return;
}
if (!$parametersMod->getValue('community', 'user', 'options', 'enable_autologin')) {
return;
}
if ($moduleGroup == 'administrator' && $moduleName == 'system' && $event == 'init') {
if (isset($_COOKIE[Config::$autologinCookieName])) {
$jsonData = $_COOKIE[Config::$autologinCookieName];
$data = json_decode($jsonData);
if ($data && isset($data->id) && isset($data->pass)) {
$tmpUser = Db::userById($data->id);
if ($tmpUser) {
if (md5($tmpUser['password'] . $tmpUser['created_on']) == $data->pass) {
$session->login($tmpUser['id']);
setCookie(Config::$autologinCookieName, json_encode(array('id' => $tmpUser['id'], 'pass' => md5($tmpUser['password'] . $tmpUser['created_on']))), time() + $parametersMod->getValue('community', 'user', 'options', 'autologin_time') * 60 * 60 * 24, Config::$autologinCookiePath, Config::getCookieDomain());
}
}
}
}
}
}
开发者ID:notzen,项目名称:ImpressPages-CMS,代码行数:27,代码来源:system.php
示例6: sendHeader
public function sendHeader()
{
// session必须要先于header处理
// 否则会覆盖header内对于Cache-Control的处理
if ($this->session) {
if (!isset($_SESSION)) {
session_start();
}
foreach ($this->session as $sess) {
list($path, $val) = $sess;
array_set($_SESSION, $path, $val);
}
$this->session = array();
}
foreach ($this->cookie as $name => $config) {
list($value, $expire, $path, $domain, $secure, $httponly) = $config;
setCookie($name, $value, $expire, $path, $domain, $secure, $httponly);
}
$this->cookie = array();
if (is_integer($this->code) && $this->code != 200) {
if ($status = self::httpStatus($this->code)) {
header($status);
}
}
foreach ($this->header as $name => $value) {
$header = $value === null ? $name : $name . ': ' . $value;
header($header);
}
$this->header = array();
return $this;
}
开发者ID:neoisldl,项目名称:Onion,代码行数:31,代码来源:response.php
示例7: cookie
static function cookie()
{
$param = func_get_args();
if (func_num_args() === 1) {
$key = $param[0];
if (is_array($param[0])) {
$key = $param[0][0];
if (isset($param[0][1]) && $param[0][1]) {
$key = secure::token($param[0][0]);
}
}
if (isset($_COOKIE[$key])) {
if (is_numeric($_COOKIE[$key]) && $_COOKIE[$key] <= 2147483647) {
return $_COOKIE[$key] + 0;
}
return secure::symbol(trim(htmlspecialchars(strip_tags($_COOKIE[$key]))));
}
return null;
}
list($key, $value) = $param;
$expire = isset($param[2]) ? $param[2] : 31536000;
if (isset($param[3]) && $param[3]) {
$key = secure::token($key);
}
$expire += time();
return setCookie($key, $value, $expire, '/', trim(SITE_DOMAIN, 'www.'));
}
开发者ID:mjiong,项目名称:framework,代码行数:27,代码来源:input.php
示例8: verify
function verify($name, $password, $remember)
{
$t = new twitter($name, $password, user_type());
$user = $t->veverify();
if (!isset($user->error) && isset($user->name)) {
$time = $remember ? time() + 3600 * 24 * 365 : 0;
setEncryptCookie('twitterID', $name, $time, '/');
setEncryptCookie('twitterPW', $password, $time, '/');
setcookie('friends_count', $user->friends_count, $time, '/');
setcookie('statuses_count', $user->statuses_count, $time, '/');
setcookie('followers_count', $user->followers_count, $time, '/');
setcookie('imgurl', $user->profile_image_url, $time, '/');
setcookie('name', $user->name, $time, '/');
$twDM = $t->directMessages(false, false, 1);
if ($twDM === false) {
} else {
if (count($twDM) == 0) {
} else {
setCookie("meSinceId", $twDM[0]->id);
}
}
return true;
} else {
return false;
}
}
开发者ID:BGCX261,项目名称:zlbnc-svn-to-git,代码行数:26,代码来源:twitese.php
示例9: clear
public static function clear()
{
$session = Factory::make('session');
$user_login_key_old = $session->get("_login_cookie_key");
setCookie($user_login_key_old, '', time() - 1, '/');
$session->clear();
}
开发者ID:longmonhau,项目名称:Half-Life,代码行数:7,代码来源:tSession.php
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Session::has('role')) {
return redirect('/login');
}
if (!isset($_COOKIE['login'])) {
$visitorCount = 1;
}
$setTime = time() + 3600;
if (isset($_COOKIE['login'])) {
$visitorCount = $_COOKIE['login'] + 1;
setCookie('login', $visitorCount, $setTime);
} else {
setCookie('login', $visitorCount, $setTime);
}
if (!Session::has('anchor')) {
session(['anchor' => '2']);
}
assert_options(ASSERT_ACTIVE, 1);
assert_options(ASSERT_WARNING, 0);
assert_options(ASSERT_QUIET_EVAL, 1);
assert_options(ASSERT_CALLBACK, 'my_assert_handler');
$old_error_handler = set_error_handler("myErrorHandler");
return $next($request);
}
开发者ID:Soul0806,项目名称:MyWeb,代码行数:32,代码来源:AuthMiddleware.php
示例11: erase
/**
* @return void
* @param string $name
*/
public function erase($name)
{
if (!headers_sent()) {
setCookie($name, null, -1, '/', $this->domain, $this->secure, $this->httpOnly);
}
unset($_COOKIE[$name]);
}
开发者ID:visor,项目名称:nano,代码行数:11,代码来源:Cookie.php
示例12: generateCookie
public static function generateCookie($jabberId, $secret)
{
$id = trim($jabberId . ":" . $secret);
$cookie = setCookie("tokboxId", $id, 0);
$url = Site_Config::BASE_SITE . "index.php";
header("Location: {$url}");
}
开发者ID:akhil-chaurasia,项目名称:tokboxapi,代码行数:7,代码来源:Callback.php
示例13: setAuthCookie
private function setAuthCookie($md5_pw)
{
$remember_time = time() + 60 * 60 * 24 * 30;
$user = $this->getSessionUser();
$auth_token = $this->createAuthToken($user->userid, $user->email, $md5_pw);
setCookie("sc_auth", $auth_token, $remember_time);
}
开发者ID:jeffreytierney,项目名称:switchcomb,代码行数:7,代码来源:SCUserSession.php
示例14: index_action
function index_action()
{
if ($_COOKIE['uid'] != "" && $_COOKIE['username'] != "") {
if ($_GET['type'] == "out") {
if ($this->config['sy_uc_type'] == "uc_center") {
$M = $this->MODEL();
$M->uc_open();
$logout = uc_user_synlogout();
} elseif ($this->config['sy_pw_type']) {
include APP_PATH . "/api/pw_api/pw_client_class_phpapp.php";
$username = $_SESSION['username'];
$pw = new PwClientAPI($username, "", "");
$logout = $pw->logout();
$this->unset_cookie();
} else {
$this->unset_cookie();
}
} else {
$this->ACT_msg("index.php", "您已经登录了!");
}
}
if ($_GET['backurl'] == '1') {
setCookie("backurl", $_SERVER['HTTP_REFERER'], time() + 60);
}
if (!$_GET['usertype']) {
$_GET['usertype'] = 1;
}
$this->yunset("usertype", $_GET['usertype']);
$this->yunset("loginname", $_COOKIE['loginname']);
$this->seo("login");
$this->yun_tpl(array('index'));
}
开发者ID:justinyaoqi,项目名称:qyhr,代码行数:32,代码来源:index.class.php
示例15: setCookie
/**
* 设置身份验证Cookie(sid)
*/
public function setCookie()
{
if (!self::$data[$this->uid]['islogin']) {
throw new userexception('用户未登陆,不能设置身份验证Cookie。', 2503);
}
return setCookie(COOKIE_A . 'sid', self::$data[$this->uid]['sid'], $_SERVER['REQUEST_TIME'] + DEFAULT_LOGIN_TIMEOUT, COOKIE_PATH, COOKIE_DOMAIN);
}
开发者ID:istrwei,项目名称:hu60wap6,代码行数:10,代码来源:user.php
示例16: counter
function counter()
{
$hits = get_option('simplevisitorcounter_data');
if (is_404()) {
if (!get_option('simplevisitorcounter_count_404')) {
// if its a 404 page and theres no explicit rule to count 404s, lets bail
return;
}
}
if (get_option('simplevisitorcounter_count_only_unique')) {
if (!$_COOKIE['simplevisitorcounter_seen']) {
setCookie("simplevisitorcounter_seen", "1", time() + 3600 * 24);
} else {
// bail if non unique and we're only counting uniques
return;
}
}
/* check if hit comes from wp-admin */
if (is_admin()) {
if (get_option('simplevisitorcounter_count_admin')) {
update_option('simplevisitorcounter_data', $hits + 1);
}
} else {
$exclude_list = split("\n", get_option('simplevisitorcounter_exclude_ips'));
if (!in_array($_SERVER['REMOTE_ADDR'], $exclude_list)) {
update_option('simplevisitorcounter_data', $hits + 1);
}
}
}
开发者ID:andripriyanto,项目名称:WebTKJ-BPI,代码行数:29,代码来源:image.php
示例17: ModulePage
function ModulePage()
{
global $PIO;
$err = '';
// 錯誤資訊
$res = isset($_GET['r']) ? intval($_GET['r']) : 0;
// 回應編號
if (isset($_GET['dm'])) {
// 是否進入設定模式
$ss = $ms = $ls = '';
switch ($this->displayMode) {
case 's':
$ss = ' selected="selected"';
break;
case 'm':
$ms = ' selected="selected"';
break;
case 'l':
$ls = ' selected="selected"';
break;
}
$this->mobileHead($err, TITLE . ' - 設定');
$err .= '<div>[<a href="' . $this->thisPage . '">回首頁</a>]<br/><form action="' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $this->thisPage) . '" method="post">顯示模式:<br/><select name="dm"><option value="s"' . $ss . '>精簡 (無圖,裁字)</option><option value="m"' . $ms . '>一般 (無圖,全字)</option><option value="l"' . $ls . '>完整 (有圖,全字)</option></select><br/><input type="submit" value="儲存"/></form></div><div id="f">-Pixmicat!m-</div></body></html>';
} else {
if (isset($_POST['dm'])) {
setCookie('dm', $this->displayMode = $_POST['dm'], time() + 604800);
}
if ($res !== 0) {
$pageMax = $page = null;
// Not in use
if (!$PIO->isThread($res)) {
$err = 'Thread Not Found';
} else {
$post = $PIO->fetchPosts($PIO->fetchPostList($res));
}
} else {
$pageMax = ceil($PIO->threadCount() / $this->THREADLIST_NUMBER) - 1;
// 分頁最大編號
$page = isset($_GET['p']) ? intval($_GET['p']) : 0;
// 目前所在分頁
if ($page < 0 || $page > $pageMax) {
$err = 'Page Out of Range';
} else {
$post = $PIO->fetchPosts($PIO->fetchThreadList($this->THREADLIST_NUMBER * $page, $this->THREADLIST_NUMBER, true));
}
// 編號由大到小排序取出
}
}
if ($err) {
echo $err;
} else {
$dat = '';
// HTML Buffer
$this->mobileHead($dat, TITLE);
$this->mobileBody($dat, $pageMax, $page, $res, $post);
$this->mobileFoot($dat);
echo $dat;
}
}
开发者ID:Kennyl,项目名称:pixmicat_modules,代码行数:59,代码来源:mod_mobile.php
示例18: index
public function index()
{
$action = I("post.action");
if ($action == 'addrecord') {
$this->assign("isAdd", true);
$domain_id = I("post.domain_id");
$name = trim(strtolower(I("post.name")));
$type = I("post.type");
$value = I("post.value");
$code = I("post.code");
if (strlen($code) != 4 || !isset($_COOKIE['verification']) || md5(strtolower($code)) !== $_COOKIE['verification']) {
$this->assign("alert", sweetAlert("温馨提示", "验证码不正确", "warning"));
} elseif (C("allowNum") == -1) {
$this->assign("alert", sweetAlert("温馨提示", "站长已经关闭用户自助解析功能!", "warning"));
} elseif (!$this->checkAllow($name)) {
$this->assign("alert", sweetAlert("温馨提示", "对不起,前缀{$name}不允许用户解析!", "warning"));
} elseif (C("allowNum") && $this->pdo->getCount("select record_id from pre_records where uid=:uid", array(":uid" => $this->userInfo['uid'])) >= C("allowNum")) {
$this->assign("alert", sweetAlert("温馨提示", "你最大允许解析" . C("allowNum") . "条记录!", "warning"));
} elseif (!($row = $this->pdo->find("select dns,name from pre_domains where domain_id=:id and level <= :level limit 1", array(":id" => $domain_id, ":level" => $this->userInfo['level'])))) {
$this->assign("alert", sweetAlert("温馨提示", "所选择域名不存在!", "warning"));
} else {
setCookie('verification', null, -1, '/');
//销毁验证码
$klsfDns = KlsfDns::getApi($row['dns']);
if ($ret = $klsfDns->addRecord($domain_id, $name, $type, $value, $row['name'])) {
$insert = array(':record_id' => $ret['record_id'], ':uid' => $this->userInfo['uid'], ':domain_id' => $domain_id, ':name' => $ret['name'], ':type' => $type, ':value' => $value);
if ($this->pdo->execute("INSERT INTO `pre_records` (`record_id`, `uid`, `domain_id`, `name`, `type`, `value`, `updatetime`) VALUES (:record_id, :uid, :domain_id, :name, :type, :value, NOW())", $insert)) {
$this->assign("isAdd", false);
$this->assign("alert", sweetAlert("添加成功", "添加记录成功!", "success"));
} else {
$this->assign("alert", sweetAlert("温馨提示", "解析成功,保存数据库失败!", "warning"));
}
} else {
$info = $klsfDns->getErrorInfo();
$this->assign("alert", sweetAlert("温馨提示", $info['msg'], "warning"));
}
}
}
//获取记录列表
$records = $this->pdo->selectAll("select a.*,b.name as domain,b.dns from pre_records as a left join pre_domains as b on b.domain_id=a.domain_id where a.uid=:uid", array(":uid" => $this->userInfo['uid']));
//获取域名列表
$domains = $this->pdo->selectAll("select * from pre_domains where `level` <= :level", array(":level" => $this->userInfo['level']));
//遍历记录检查是否还存在,不存在则从数据库删除
$newRecords = array();
foreach ($records as $record) {
$klsfDns = KlsfDns::getApi($record['dns']);
if ($re = $klsfDns->getRecordInfo($record['domain_id'], $record['record_id'])) {
$re['domain'] = $record['domain'];
$newRecords[] = $re;
} else {
//不存在则删除记录
$this->pdo->execute("delete from pre_records where record_id=:id limit 1", array(":id" => $record['record_id']));
}
}
$this->assign("records", $newRecords);
$this->assign("domains", $domains);
$this->assign("webTitle", "控制面板");
return $this->fetch();
}
开发者ID:klsf,项目名称:kldns,代码行数:59,代码来源:Panel.php
示例19: logOut
public function logOut()
{
setCookie('username', '', 0, '/');
setCookie('pwd', '', 0, '/');
unset($_SESSION);
session_destroy();
$this->redirect('Login/index');
}
开发者ID:kimcerry,项目名称:share,代码行数:8,代码来源:LoginController.class.php
示例20: setAuthToken
function setAuthToken($uid)
{
$rnd = md5(uniqid(rand(), true));
$sql = "UPDATE lylina_users\n SET magic = '{$rnd}'\n WHERE id = {$uid}";
runSQL($sql);
setCookie('lylina_auth', $rnd, time() + 60 * 60 * 24 * 365);
setCookie('lylina_uid', $uid, time() + 60 * 60 * 24 * 365);
}
开发者ID:eharmon,项目名称:yelly,代码行数:8,代码来源:auth.php
注:本文中的setCookie函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论