本文整理汇总了PHP中setrawcookie函数的典型用法代码示例。如果您正苦于以下问题:PHP setrawcookie函数的具体用法?PHP setrawcookie怎么用?PHP setrawcookie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setrawcookie函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: s_cookie_set
function s_cookie_set($key, $val, $exp, $path)
{
if (s_bad_string($key)) {
return false;
}
return setrawcookie($key, $val);
}
示例2: retrieveByCredentials
/**
* Retrieve a user by the given credentials.
*
* @param array $credentials
* @return $userModel|null
*/
public function retrieveByCredentials(array $credentials = array())
{
if (empty($credentials)) {
if ($this->isTokenValid($this->tokenId)) {
$this->setUser($this->tokenId);
return $this->userModel;
} else {
return null;
}
}
$authenticateUri = "/openam/json/authenticate";
if (!is_null($this->realm)) {
$authenticateUri = "/openam/json/" . $this->realm . "/authenticate";
}
$ch = curl_init($this->serverAddress . $authenticateUri);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-OpenAM-Username: ' . $credentials['username'], 'X-OpenAM-Password: ' . $credentials['password'], 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$output = curl_exec($ch);
if ($output === false) {
$curlError = curl_error($ch);
curl_close($ch);
throw new Exception('Curl error: ' . $curlError);
} else {
$json = json_decode($output);
$this->tokenId = $json->tokenId;
$this->setUser($this->tokenId);
curl_close($ch);
setrawcookie($this->cookieName, $this->tokenId, 0, $this->cookiePath, $this->cookieDomain);
return $this->userModel;
}
}
示例3: processConnection
/**
* process form data for submission to your Act-On external form URL
* @param string $extPostUrl your external post (Proxy URL) for your Act-On "proxy" form
*/
public function processConnection($extPostUrl)
{
$this->setPostItems('_ipaddr', $this->getUserIP());
// Act-On accepts manually defined IPs if using field name '_ipaddr'
$fields = http_build_query($this->getPostItems());
// encode post items into query-string
$handle = curl_init();
curl_setopt($handle, CURLOPT_POST, 1);
curl_setopt($handle, CURLOPT_URL, "{$extPostUrl}");
curl_setopt($handle, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($handle, CURLOPT_HEADER, 1);
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($handle, CURLOPT_POSTFIELDS, $fields);
$response = curl_exec($handle);
if ($response === FALSE) {
$response = "cURL Error: " . curl_error($handle);
} else {
preg_match_all('/^Set-Cookie:\\040wp\\s*([^;]*)/mi', $response, $ra);
// pull response "set-cookie" values from cURL response header
parse_str($ra[1][0], $cookie);
// select the "set-cookie" for visitor conversion and store to array $cookie
// set updated website visitor tracking cookie with processed "set-cookie" content from curl
setrawcookie('wp' . key($cookie), implode(",", $cookie), time() + 86400 * 365, "/", $this->getDomain($extPostUrl));
// set cookie expiry date to 1 year
}
curl_close($handle);
}
示例4: testHeaderSentCookies
/**
* @return string
*/
public function testHeaderSentCookies()
{
$_COOKIE['test0'] = 'test0';
// Create cookies :
setcookie('test1', 'test1');
setcookie('test2', 'test2');
setrawcookie('test3', 'test3');
setrawcookie('test4', 'test4');
// Delete, created cookies (with false) :
setcookie('test1', false);
setrawcookie('test2', false);
// Delete, created cookies (with null) :
setcookie('test3', null);
setrawcookie('test4', null);
// Delete others cookies :
setcookie('testDeleteOther0', null);
setrawcookie('testDeleteOther1', null);
// Not send REQUEST_TIME + 0 :
setrawcookie('testKeyNotSend', 'testValueNotSend', REQUEST_TIME + 0);
$listOfHeaders = headers_list();
ob_start();
print_r($listOfHeaders);
$result = ob_get_clean();
$lines = $this->outputTestLineLayout($this->highlightPhp("\$_COOKIE['test0'] = 'test0';\n\n// Create cookies :\nsetcookie('test1', 'test1');\nsetcookie('test2', 'test2');\nsetrawcookie('test3', 'test3');\nsetrawcookie('test4', 'test4');\n\n// Delete, created cookies (with false) :\nsetcookie('test1', false);\nsetrawcookie('test2', false);\n\n// Delete, created cookies (with null) :\nsetcookie('test3', null);\nsetrawcookie('test4', null);\n\n// Delete others cookies :\nsetcookie('testDeleteOther0', null);\nsetrawcookie('testDeleteOther1', null);\n\n// Not send REQUEST_TIME + 0 :\nsetrawcookie('testKeyNotSend', 'testValueNotSend', REQUEST_TIME + 0);"), $this->getDefaultTestLineTitle());
$lines .= $this->outputTestLineLayout($this->highlightPhp($result, false), self::getDefaultTestResultTitle());
return $this->outputTestLayout($lines, 'Headers - Create cookies, sent cookies and print headers sent');
}
示例5: iflychat_get_current_guest_id
function iflychat_get_current_guest_id()
{
if (isset($_SESSION) && isset($_SESSION['iflychat_guest_id'])) {
//if(!isset($_COOKIE) || !isset($_COOKIE['drupalchat_guest_id'])) {
setrawcookie('iflychat_guest_id', rawurlencode($_SESSION['iflychat_guest_id']), time() + 60 * 60 * 24 * 365);
setrawcookie('iflychat_guest_session', rawurlencode($_SESSION['iflychat_guest_session']), time() + 60 * 60 * 24 * 365);
//}
} else {
if (isset($_COOKIE) && isset($_COOKIE['iflychat_guest_id']) && isset($_COOKIE['iflychat_guest_session']) && $_COOKIE['iflychat_guest_session'] == iflychat_compute_guest_session($_COOKIE['iflychat_guest_id'])) {
$_SESSION['iflychat_guest_id'] = check_plain($_COOKIE['iflychat_guest_id']);
$_SESSION['iflychat_guest_session'] = check_plain($_COOKIE['iflychat_guest_session']);
} else {
$characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
$iflychatId = time();
for ($i = 0; $i < 5; $i++) {
$iflychatId .= $characters[rand(0, strlen($characters) - 1)];
}
$_SESSION['iflychat_guest_id'] = $iflychatId;
$_SESSION['iflychat_guest_session'] = iflychat_compute_guest_session($_SESSION['iflychat_guest_id']);
setrawcookie('iflychat_guest_id', rawurlencode($_SESSION['iflychat_guest_id']), time() + 60 * 60 * 24 * 365);
setrawcookie('iflychat_guest_session', rawurlencode($_SESSION['iflychat_guest_session']), time() + 60 * 60 * 24 * 365);
}
}
return $_SESSION['iflychat_guest_id'];
}
示例6: setLocalCookie
function setLocalCookie($header)
{
$header_arr = explode("\n", $header);
foreach ($header_arr as $header_each) {
if (strpos($header_each, 'Set-Cookie') !== false) {
$p1 = strpos($header_each, "=");
$p2 = strpos($header_each, ";");
$name = substr($header_each, 12, $p1 - 12);
$value = substr($header_each, $p1 + 1, $p2 - $p1 - 1);
$expires = null;
switch ($name) {
case "cap_id":
case "_xsrf":
// 30 days
$expires = time() + 60 * 60 * 24 * 30;
break;
case "q_c1":
case "_za":
case "z_c0":
// 3 years
$expires = time() + 60 * 60 * 24 * 365 * 3;
break;
case "unlock_ticket":
// 4 hours
$expires = time() + 60 * 60 * 4;
break;
}
setrawcookie($name, $value, $expires, "/");
}
}
}
示例7: set
public function set($key, $value)
{
// raw url encode and set raw cookie used here to prevent issues with spaces encoded as '+'
$value = rawurlencode(json_encode($value));
setrawcookie($this->cookie_prefix . $key, $value, time() + $this->app['config']['cookie_lifetime'], '/');
$_COOKIE[$this->cookie_prefix . $key] = $value;
}
示例8: add_event
/**
* Adds a setting to the frame events
* @param type $data
* @return type
*/
function add_event($data)
{
$id = md5(serialize($data));
$data['context'] = $this->object->context;
setrawcookie($this->object->setting_name . '_' . $id, $this->object->_encode($data));
return $data;
}
示例9: setRaw
public function setRaw($name, $value = "", $expire = 0, $path = null, $domain = null, $secure = false, $httponly = false)
{
if (!setrawcookie($name, $value, $expire, $path, $domain, $secure, $httponly)) {
throw new Exception("Cookie could not be set.");
}
return $this;
}
示例10: setrawcookie
public static function setrawcookie($key, $value = '', $expire = 0, $path = '/', $domain = '', $secure = false, $httponly = false)
{
if (self::$_response) {
self::$_response->rawcookie($key, $value, $expire, $path, $domain, $secure, $httponly);
}
\setrawcookie($key, $value, $expire, $path, $domain, $secure, $httponly);
}
示例11: execute
/**
* @see ExpressoLite\Backend\Request\LiteRequest::execute
*/
public function execute()
{
if (!$this->isParamSet('user') || !$this->isParamSet('pwd')) {
$this->httpError(400, 'É necessário informar login e senha.');
}
try {
$this->resetTineSession();
$result = $this->tineSession->login($this->param('user'), $this->param('pwd'), $this->isParamSet('captcha') ? $this->param('captcha') : null);
} catch (PasswordExpiredException $pe) {
return (object) array('success' => false, 'expired' => true);
} catch (CaptchaRequiredException $cre) {
return (object) array('success' => false, 'captcha' => $cre->getCaptcha());
}
if ($result) {
$cookiePath = str_replace('accessible/', '', $_SERVER['REQUEST_URI']);
//we remove 'accessible/' suffix from current path.
//This way, the cookie will always be set to all modules,
//even if it was started by the accessible module
setrawcookie('user', $this->param('user'), time() + 60 * 60 * 24 * 30, $cookiePath);
$_COOKIE['user'] = $this->param('user');
//setrawcookie() does not update the $_COOKIE array with the new cookie.
//So, we do this manually to avoid problems with checkIfSessionUserIsValid
//later on
}
$this->checkIfSessionUserIsValid();
// Its better to check if the tine user matches Expresso Lite user
// right away
return (object) array('success' => $result, 'userInfo' => (object) array('mailAddress' => $this->tineSession->getAttribute('Expressomail.email'), 'mailSignature' => $this->tineSession->getAttribute('Expressomail.signature'), 'mailBatch' => MAIL_BATCH));
}
示例12: clearcookie
function clearcookie()
{
if (is_array($_COOKIE)) {
foreach ($_COOKIE as $key => $val) {
setrawcookie($key, '', -86400 * 365, $GLOBALS['cookiecfg']['path'], $GLOBALS['cookiecfg']['domain'], $_SERVER['SERVER_PORT'] == 443 ? 1 : 0);
}
}
}
示例13: set
public function set()
{
if ($this->raw) {
setrawcookie($this->name, $this->value, $this->expire, $this->path, $this->domain, $this->secure, $this->httponly);
} else {
setcookie($this->name, $this->value, $this->expire, $this->path, $this->domain, $this->secure, $this->httponly);
}
}
示例14: store_uid
public static function store_uid($uid = '')
{
if (!headers_sent()) {
setrawcookie(self::COOKIE, $uid, time() + 60 * 60 * 24 * 30, COOKIEPATH, COOKIE_DOMAIN);
do_action('edd_segment_uid_stored', $uid);
}
return $uid;
}
示例15: checkLogin
function checkLogin()
{
print "Here";
if (!($connect = mysqli_connect("localhost", "root", "", "ita_project"))) {
die("Error in connecting to the database");
}
$username = $_POST['username'];
$password = $_POST['password'];
$query = "select * from student where uname = '" . $username . "' and password = '" . $password . "'";
if (!($result = mysqli_query($connect, $query))) {
die("Error in querying");
}
$count = 0;
while ($row = mysqli_fetch_array($result)) {
$count++;
}
if ($count >= 1) {
setrawcookie("CRG", $username, time() + 1800);
//setrawcookie("CRG_SES" , time());
return 1;
}
$query = "select * from faculty where uname = '" . $username . "' and password = '" . $password . "'";
if (!($result = mysqli_query($connect, $query))) {
die("Error in querying");
}
$count = 0;
while ($row = mysqli_fetch_array($result)) {
$count++;
}
if ($count >= 1) {
//print("Login successful for faculty");
setrawcookie("CRG", $username, time() + 1800);
//setrawcookie("CRG_SES" , time());
return 2;
}
$query = "select * from admin where uname = '" . $username . "' and password = '" . $password . "'";
if (!($result = mysqli_query($connect, $query))) {
die("Error in querying");
}
$count = 0;
while ($row = mysqli_fetch_array($result)) {
$count++;
}
if ($count >= 1) {
//print("Login successful for admin");
setrawcookie("CRG", $username, time() + 1800);
//setrawcookie("CRG_SES" , time());
return 3;
}
if ($count == 0) {
return 4;
}
}