本文整理汇总了PHP中SugarApplication::setCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarApplication::setCookie方法的具体用法?PHP SugarApplication::setCookie怎么用?PHP SugarApplication::setCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SugarApplication
的用法示例。
在下文中一共展示了SugarApplication::setCookie方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initSharedSession
/**
* Initiates Shared Session
*/
protected function initSharedSession()
{
$cookie_name = $this->getSharedSessionCookieName();
if (isset($_COOKIE[$cookie_name])) {
$data = $this->parseSignedRequest($_COOKIE[$cookie_name]);
if ($data && !empty($data['domain']) && self::isAllowedDomain($this->getHttpHost(), $data['domain'])) {
// good case
$this->sharedSessionID = $data['id'];
return;
}
// ignoring potentially unreachable data
}
// evil/corrupt/missing case
$base_domain = $this->getBaseDomain();
$this->sharedSessionID = md5(uniqid(mt_rand(), true));
$cookie_value = $this->makeSignedRequest(array('domain' => $base_domain, 'id' => $this->sharedSessionID));
$_COOKIE[$cookie_name] = $cookie_value;
if (!headers_sent()) {
$expire = time() + self::FBSS_COOKIE_EXPIRE;
SugarApplication::setCookie($cookie_name, $cookie_value, $expire, '/', '.' . $base_domain, false, true);
} else {
// @codeCoverageIgnoreStart
self::errorLog('Shared session ID cookie could not be set! You must ensure you ' . 'create the Facebook instance before headers have been sent. This ' . 'will cause authentication issues after the first request.');
// @codeCoverageIgnoreEnd
}
}
示例2: time
global $app_language, $sugar_config;
//we don't want the parent module's string file, but rather the string file specifc to this subpanel
global $current_language;
// Get the login page image
if (sugar_is_file('custom/include/images/sugar_md.png')) {
$login_image = '<IMG src="custom/include/images/sugar_md.png" alt="Sugar" width="340" height="25">';
} else {
$login_image = '<IMG src="include/images/sugar_md_open.png" alt="Sugar" width="340" height="25" style="margin: 5px 0;">';
}
$sugar_smarty->assign('LOGIN_IMAGE', $login_image);
// See if any messages were passed along to display to the user.
if (isset($_COOKIE['loginErrorMessage'])) {
if (!isset($_REQUEST['loginErrorMessage'])) {
$_REQUEST['loginErrorMessage'] = $_COOKIE['loginErrorMessage'];
}
SugarApplication::setCookie('loginErrorMessage', '', time() - 42000, '/');
}
if (isset($_REQUEST['loginErrorMessage'])) {
if (isset($mod_strings[$_REQUEST['loginErrorMessage']])) {
echo "<p align='center' class='error' > " . $mod_strings[$_REQUEST['loginErrorMessage']] . "</p>";
} else {
if (isset($app_strings[$_REQUEST['loginErrorMessage']])) {
echo "<p align='center' class='error' > " . $app_strings[$_REQUEST['loginErrorMessage']] . "</p>";
}
}
}
$lvars = $GLOBALS['app']->getLoginVars();
$sugar_smarty->assign("LOGIN_VARS", $lvars);
foreach ($lvars as $k => $v) {
$sugar_smarty->assign(strtoupper($k), $v);
}
示例3: testsetCookie
public function testsetCookie()
{
//execute the method and check that the method adds the key value pair to cookies array.
SugarApplication::setCookie('key', 'value');
$this->assertEquals('value', $_COOKIE['key']);
}