本文整理汇总了PHP中SetCookie函数的典型用法代码示例。如果您正苦于以下问题:PHP SetCookie函数的具体用法?PHP SetCookie怎么用?PHP SetCookie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetCookie函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Refresh
function Refresh($toHere = 'logout.php', $session_id = '', $domain = 'default')
{
global $DCLINFO, $DCLUI;
if (!empty($_SERVER)) {
extract($_SERVER);
}
$bIsLogin = substr($toHere, 0, 10) == 'logout.php';
if ($bIsLogin) {
$theCookie = '';
if (isset($QUERY_STRING) && $QUERY_STRING != '') {
$toHere .= sprintf('%srefer_to=%s', strpos($toHere, '?') > 0 ? '&' : '?', urlencode($QUERY_STRING));
}
} else {
$theCookie = $session_id . '/' . $domain;
}
if (DCL_COOKIE_METHOD == 'header') {
$hdr = '';
if (DCL_REDIR_METHOD == 'php') {
$hdr = "Location: {$toHere}\n";
}
$hdr .= "Set-Cookie: DCLINFO={$theCookie}\n";
$hdr .= "\n";
Header($hdr);
if ($bIsLogin) {
exit;
}
}
if (DCL_COOKIE_METHOD == 'php') {
$httpDomain = '';
if (ereg('^[0-9]{2,3}\\.[0-9]{2,3}\\.[0-9]{2,3}\\.[0-9]{2,3}$', $HTTP_HOST)) {
$httpDomain = $HTTP_HOST;
} else {
if (ereg('.*\\..*$', $HTTP_HOST)) {
$httpDomain = eregi_replace('^www\\.', '', $HTTP_HOST);
$httpDomain = '.' . $httpDomain;
}
}
if (($p = strpos($httpDomain, ':')) !== false) {
$httpDomain = substr($httpDomain, 0, $p);
}
SetCookie('DCLINFO', $theCookie, 0, '/', $httpDomain);
if (DCL_REDIR_METHOD == 'php') {
Header("Location: {$toHere}\n\n");
if ($bIsLogin) {
exit;
}
}
}
print '<html><head>';
if (DCL_COOKIE_METHOD == 'meta') {
print "<meta http-equiv=\"Set-Cookie\" content=\"DCLINFO={$theCookie}\">";
}
print "<meta http-equiv=\"refresh\" content=\"00;URL={$toHere}\">";
print '</head>';
if ($bIsLogin) {
print '<body bgcolor="#FFFFFF"></body></html>';
exit;
}
}
示例2: delCookie
public function delCookie($name)
{
try {
SetCookie($name, "");
} catch (Exception $e) {
throw Exeption::ThrowDef('Failed delete cookie var - ' . $e);
}
}
示例3: loginout_action
function loginout_action()
{
SetCookie("comname", "", time() - 286400, "/");
SetCookie("comid", "", time() - 286400, "/");
SetCookie("uid", "", time() - 286400, "/");
SetCookie("username", "", time() - 86400, "/");
SetCookie("salt", "", time() - 86400, "/");
$this->wapheader('index.php');
}
示例4: updateCookie
function updateCookie($userSession) {
SetCookie("spotsession",
$userSession['session']['sessionid'] . '.' . $userSession['user']['userid'],
time()+60*60*24*30,
'', # path: The default value is the current directory that the cookie is being set in.
$this->_settings->get('cookie_host'),
false, # Indicates if the cookie should only be transmitted over a secure HTTPS connection from the client.
true); # Only available to the HTTP protocol. This means that the cookie won't be accessible by scripting languages, such as JavaScript.
} # updateCookie
示例5: login
function login($email, $password)
{
$query = mysql_query("SELECT * FROM users WHERE email='" . $email . "' AND password = '" . $password . "' AND allowed");
if ($res = mysql_fetch_array($query)) {
SetCookie("user", md5($res['email'] . '' . $res["password"]), 0);
return true;
} else {
return false;
}
}
示例6: session
function session($cache)
{
$session = empty($_COOKIE['tsvshop']) ? md5(uniqid(rand())) : $_COOKIE['tsvshop'];
SetCookie("tsvshop", $session, time() + 7200, "/");
//set the cookie to remain for 2 hours
if ($cache) {
$cache->cache("session", "tsvshop", $session);
}
return $session;
}
示例7: setCartData
public function setCartData()
{
$cart_content = serialize($_SESSION['cart']);
// сериализует данные корзины из сессии в строку
SetCookie("cart", $cart_content, time() + 3600 * 24 * 365);
//записывает сериализованную строку в куки, хранит 1 год
/* echo "<pre>";
var_dump($cart_content);
echo "</pre>";*/
}
示例8: login
function login($email, $password)
{
$query = mysql_query("SELECT * FROM users WHERE email='" . $email . "' AND password = '" . $password . "' AND allowed");
if ($res = mysql_fetch_array($query)) {
mysql_query("INSERT INTO loginlog (user_id,ip) VALUES ('" . $res['id'] . "','" . $_SERVER["REMOTE_ADDR"] . "')");
SetCookie("user", md5($res['email'] . '' . $res["password"]), 0);
return true;
} else {
return false;
}
}
示例9: index_action
function index_action()
{
if ($_POST) {
if ($_POST['femail'] == "" || $_POST['myemail'] == "" || $_POST['authcode'] == "") {
echo "请完整填写信息!";
die;
}
session_start();
if (md5($_POST['authcode']) != $_SESSION['authcode']) {
unset($_SESSION['authcode']);
echo "验证码不正确!";
die;
}
if ($_COOKIE["sendresume"] == $_POST['id']) {
echo "请不要频繁发送邮件!同一简历发送间隔为两分钟!";
die;
}
if ($this->config["sy_smtpserver"] == "" || $this->config["sy_smtpemail"] == "" || $this->config["sy_smtpuser"] == "") {
echo "网站邮件服务器不可用!";
die;
}
if ($this->CheckRegEmail(trim($_POST['femail'])) == false) {
echo "邮箱格式错误!";
die;
}
$contents = file_get_contents($this->config[sy_weburl] . "/resume/index.php?c=sendresume&id=" . $_POST['id']);
$smtp = $this->email_set();
$smtpusermail = $this->config['sy_smtpemail'];
$myemail = $this->stringfilter($_POST['myemail']);
$sendid = $smtp->sendmail($_POST['femail'], $smtpusermail, "您的好友" . $myemail . "向您推荐了简历!", $contents, "HTML", "", "", "", $myemail);
if ($sendid) {
echo 1;
} else {
echo "邮件发送错误 原因:1邮箱不可用 2网站关闭邮件服务";
die;
}
SetCookie("sendresume", $_POST['id'], time() + 120, "/");
die;
}
if ($_GET['id']) {
$M = $this->MODEL('resume');
$id = (int) $_GET['id'];
$user = $M->resume_select($id);
$this->yunset("Info", $user);
$data['resume_username'] = $user['username_n'];
$data['resume_city'] = $user['city_one'] . "," . $user['city_two'];
$data['resume_job'] = $user['hy'];
$this->data = $data;
}
$this->seo("resume_share");
$this->yun_tpl(array('resume_share'));
}
示例10: han_rand
public function han_rand()
{
header("Content-type: text/html; charset=utf-8");
session_start();
if (empty($_COOKIE['graee_rand'])) {
$rand = "han_" . rand(100000, 999999) . "_" . mktime();
//记录到cookie中
SetCookie("graee_rand", $rand, time() + 3600 * 24);
//3600秒=1小时 过期时间为24小时
//记录到session中
$_SESSION['graee_rand'] = $rand;
//设置session存活时间
$lifeTime = 24 * 3600;
session_set_cookie_params($lifeTime);
}
}
示例11: load_account
function load_account()
{
global $sql;
global $site;
global $auth;
/* Sélection de la base de données du site */
$sql->selection_bd($auth->db_auth);
$sql->requete("SELECT numchars FROM `realmcharacters` WHERE acctid = '" . $this->sess_id . "'", 0);
while ($val = $sql->resultat(0, "array")) {
$this->nb_char = $this->nb_char + $val['numchars'];
}
if ($this->nb_char > 0) {
$this->load_characters();
}
$sql->selection_bd($site->db_site);
$sql->requete("SELECT * FROM `users` WHERE id = '" . $this->sess_id . "'", 0);
$this->array_user = $sql->resultat(0, "array");
$this->sess_user = $this->array_user['login'];
$this->level = $this->array_user['niveau'];
$this->email = $this->array_user['mail'];
$sql->requete("SELECT * FROM `voting` WHERE user_ip = '" . $this->ipaddr . "'", 0);
$val = $sql->resultat(0, "array");
if (!$val) {
$sql->requete("INSERT INTO `voting` (`user_ip`) VALUES ('" . $this->ipaddr . "')", 0);
$sql->requete("SELECT * FROM `voting` WHERE user_ip = '" . $this->ipaddr . "'", 0);
$val = $sql->resultat(0, "array");
}
$this->array_voting = $val;
$sql->requete("SELECT * FROM `voting_points` WHERE id = '" . $this->sess_id . "'", 0);
$this->array_voting_points = $sql->resultat(0, "array");
$sql->requete("UPDATE users SET last_ip = '" . $this->ipaddr . "' WHERE id = '" . $this->sess_id . "'", 0);
if ($this->cookie) {
$p = SHA1($this->sess_user);
SetCookie("conection1", $p, time() + 3600 * 48);
SetCookie("conection2", $rmd5, time() + 3600 * 48);
}
}
示例12: or
<?php
/*
Copyright Intermesh 2003
Author: Merijn Schering <mschering@intermesh.nl>
Version: 1.0 Release date: 08 July 2003
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
*/
require "../Group-Office.php";
$GO_SECURITY->authenticate();
if (isset($_REQUEST['search_field'])) {
SetCookie("user_search_field", $_REQUEST['search_field'], time() + 3600 * 24 * 365, "/", "", 0);
$_COOKIE['user_search_field'] = $_REQUEST['search_field'];
}
$GO_HEADER['body_arguments'] = 'class="TableInside"';
require $GO_THEME->theme_path . "header.inc";
echo '<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td class="TableInside" valign="top">';
if (isset($_REQUEST['project_acl'])) {
require $GO_LANGUAGE->get_language_file('projects');
}
$acl = new acl($_REQUEST['acl_id'], isset($_REQUEST['acl_table']) ? $_REQUEST['acl_table'] : 'acl');
echo '</td></tr></table>';
require $GO_THEME->theme_path . "footer.inc";
示例13: GetParamsFromCookie
private function GetParamsFromCookie()
{
$cookieName = COption::GetOptionString("main", "cookie_name", "FREETRIX_SM")."_ADM_FLT_PARAMS";
if(!isset($_COOKIE[$cookieName]) || $_COOKIE[$cookieName] == "")
return false;
$aParams = explode(",",$_COOKIE[$cookieName]);
SetCookie($cookieName,'');
if(empty($aParams))
return false;
$filterId = "";
foreach ($aParams as $key => $aValue)
{
$aParam = explode(":",$aValue);
unset($aParams[$key]);
if(!empty($aParam) && $aParam[0] != "filter_id")
$aParams[$aParam[0]] = $aParam[1];
elseif($aParam[0] == "filter_id")
$filterId = $aParam[1];
}
if($filterId == "")
return false;
foreach ($aParams as $paramName => $value)
$_SESSION[self::SESS_PARAMS_NAME][$filterId][$paramName] = $value;
return true;
}
示例14: header_end
function header_end()
{
SetCookie("bNewsDate", $this->_TIME, $this->_TIME + 24 * 60 * 60);
return "\t\t</form>\n\t\t\t\t\t</div>\n\t\t\t\t</div>";
}
示例15: exit
exit("Stop! Forbidden");
}
if (empty($_GET)) {
// Главная
} else {
// Не главная
}
if (!empty($_POST["update"])) {
SetCookie("new_version_system", "", time() - 3600 * 10000);
}
if (!empty($_POST["menu_as"])) {
// меню админки
if (isset($_COOKIE["menu_as"])) {
SetCookie("menu_as", "", time() - 3600 * 10000);
} else {
SetCookie("menu_as", "true", time() + 3600 * 24 * 7, "/");
}
}
/*$arr = Array(
"default" => "blog"
);
$db = New DB();
$db -> installSettings("public_applications", $arr);*/
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>APPS-SYSTEM</title>