本文整理汇总了PHP中Zend_Http_Cookie类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Cookie类的具体用法?PHP Zend_Http_Cookie怎么用?PHP Zend_Http_Cookie使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Http_Cookie类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: loginAction
/**
* ログイン処理 Action
*
* @return void
*/
public function loginAction()
{
$req = $this->getRequest();
$res = $this->getResponse();
$controllerName = $req->getControllerName();
$loginName = $req->getparam('userName');
$password = $req->getparam('password');
$garoonApi = new GaroonApiLib();
$result = $garoonApi->utilLogin($loginName, $password);
if ($result->status === 'Login') {
$loginResult = explode('=', $result->cookie);
// ログイン情報をcookieに出力
$cookie = new Zend_Http_Cookie($loginResult[0], $loginResult[1], 'localhost');
$res->setHeader('Set-Cookie', $cookie->__toString());
// ログインユーザー情報取得
$searchUserName = array();
$searchUserName[] = $loginName;
$userInfo = $garoonApi->baseGetUsersByLoginName($searchUserName, $loginResult[1]);
$userId = $userInfo->user->key;
$userName = $userInfo->user->name;
$loginUserInfo = array();
$loginUserInfo['loginName'] = $loginName;
$loginUserInfo['userId'] = $userId;
$loginUserInfo['userName'] = $userName;
$this->view->assign('loginInfo', $loginUserInfo);
$displayContent = $this->view->render($controllerName . '/input.tpl');
} else {
$this->view->assign('errorMessage', 'ログインに失敗しました。');
$displayContent = $this->view->render($controllerName . '/error.tpl');
}
// 表示
$res->setBody($displayContent);
}
开发者ID:Hackason-TemaShibasaki,项目名称:ProjectHackathon,代码行数:38,代码来源:Test001Controller.php
示例2: addCookie
public function addCookie($cookie, $ref_uri = null)
{
if (is_string($cookie)) {
if ($this->_encodeCookie) {
$cookie = Zend_Http_Cookie::fromString($cookie, $ref_uri);
} else {
$cookie = Zend_Http_Cookie::fromString($cookie, $ref_uri, false);
}
}
if ($cookie instanceof Zend_Http_Cookie) {
$domain = $cookie->getDomain();
$path = $cookie->getPath();
if (!isset($this->cookies[$domain])) {
$this->cookies[$domain] = array();
}
if (!isset($this->cookies[$domain][$path])) {
$this->cookies[$domain][$path] = array();
}
$this->cookies[$domain][$path][$cookie->getName()] = $cookie;
$this->_rawCookies[] = $cookie;
} else {
require_once 'Zend/Http/Exception.php';
throw new Zend_Http_Exception('Supplient argument is not a valid cookie string or object');
}
}
开发者ID:sb15,项目名称:zend-ex-legacy,代码行数:25,代码来源:CookieJar.php
示例3: testIsSecure
public function testIsSecure()
{
foreach ($this->secureTests as $cookieStr) {
$cookie = Zend_Http_Cookie::factory($cookieStr);
$this->assertTrue($cookie->isSecure());
}
foreach ($this->nonSecureTests as $cookieStr) {
$cookie = Zend_Http_Cookie::factory($cookieStr);
$this->assertFalse($cookie->isSecure());
}
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:11,代码来源:CookieTest.php
示例4: unsetCookie
public function unsetCookie()
{
// Check if HttpCookieObject exists
$this->getHttpCookieObject();
$name = $this->httpCookieObject->getName();
$expire = $this->httpCookieObject->getExpiryTime();
$path = $this->httpCookieObject->getPath();
$domain = $this->httpCookieObject->getDomain();
$secure = $this->httpCookieObject->isSecure();
$value = null;
$httpCookieObject = new Zend_Http_Cookie($name, $value, $domain, $expire, $path, $secure);
$this->setHttpCookieObject($httpCookieObject);
return $this->write();
}
开发者ID:massimozappino,项目名称:zmz,代码行数:14,代码来源:Cookie.php
示例5: addCookie
/**
* Add a cookie to the jar. Cookie should be passed either as a Zend_Http_Cookie object
* or as a string - in which case an object is created from the string.
*
* @param Zend_Http_Cookie|string $cookie
* @param Zend_Uri_Http|string $red_uri Optional reference URI (for domain, path, secure)
*/
public function addCookie($cookie, $ref_uri = null)
{
if (is_string($cookie)) {
$cookie = Zend_Http_Cookie::fromString($cookie, $ref_uri);
}
if ($cookie instanceof Zend_Http_Cookie) {
$domain = $cookie->getDomain();
$path = $cookie->getPath();
if (!isset($this->cookies[$domain])) {
$this->cookies[$domain] = array();
}
if (!isset($this->cookies[$domain][$path])) {
$this->cookies[$domain][$path] = array();
}
$this->cookies[$domain][$path][$cookie->getName()] = $cookie;
} else {
throw Zend::exception('Zend_Http_Exception', 'Supplient argument is not a valid cookie string or object');
}
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:26,代码来源:CookieJar.php
示例6: testIteratorAndCountable
public function testIteratorAndCountable()
{
$jar = new Zend_Http_CookieJar();
$cookies = array(Zend_Http_Cookie::fromString('foo1=bar1; domain=.example.com; path=/a/b'), Zend_Http_Cookie::fromString('foo2=bar2; domain=.example.com; path=/a/b/'));
foreach ($cookies as $cookie) {
$jar->addCookie($cookie);
}
foreach ($jar as $cookie) {
$this->assertTrue($cookie instanceof Zend_Http_Cookie);
}
$this->assertEquals(2, count($jar));
$this->assertFalse($jar->isEmpty());
$jar->reset();
$this->assertTrue($jar->isEmpty());
}
开发者ID:JeancarloPerez,项目名称:booking-system,代码行数:15,代码来源:CookieJarTest.php
示例7: testSetCookieObjectJar
/**
* Make sure we can set cookie objects with a jar
*
*/
public function testSetCookieObjectJar()
{
$this->client->setUri($this->baseuri . 'testCookies.php');
$this->client->setCookieJar();
$refuri = $this->client->getUri();
$cookies = array(Zend_Http_Cookie::fromString('chocolate=chips', $refuri), Zend_Http_Cookie::fromString('crumble=apple', $refuri));
$strcookies = array();
foreach ($cookies as $c) {
$this->client->setCookie($c);
$strcookies[$c->getName()] = $c->getValue();
}
$res = $this->client->request();
$this->assertEquals($res->getBody(), serialize($strcookies), 'Response body does not contain the expected cookies');
}
开发者ID:lortnus,项目名称:zf1,代码行数:18,代码来源:SocketTest.php
示例8: testFromStringFalse
public function testFromStringFalse()
{
$cookie = Zend_Http_Cookie::fromString('foo; domain=www.exmaple.com');
$this->assertEquals(false, $cookie, 'fromString was expected to fail and return false');
$cookie = Zend_Http_Cookie::fromString('=bar; secure; domain=foo.nl');
$this->assertEquals(false, $cookie, 'fromString was expected to fail and return false');
$cookie = Zend_Http_Cookie::fromString('fo;o=bar; secure; domain=foo.nl');
$this->assertEquals(false, $cookie, 'fromString was expected to fail and return false');
}
开发者ID:lortnus,项目名称:zf1,代码行数:9,代码来源:CookieTest.php
示例9: testGetMatchingCookiesAsStrings
/**
* Test we can get all matching cookies for a request, and return as strings array / concat
*/
public function testGetMatchingCookiesAsStrings()
{
$jar = new Zend_Http_CookieJar();
$cookies = array(Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 3600)), Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)), Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'), Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() + 3600)), Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)), Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)), Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)));
foreach ($cookies as $cookie) {
$jar->addCookie($cookie);
}
$this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8');
$cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_STRING_ARRAY);
$this->assertType('array', $cookies, '$cookies is expected to be an array, but it is not');
$this->assertType('string', $cookies[0], '$cookies[0] is expected to be a string');
$cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT);
$this->assertType('string', $cookies, '$cookies is expected to be a string');
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:17,代码来源:CookieJarTest.php
示例10: setCookie
/**
* Add a cookie to the request. If the client has no Cookie Jar, the cookies
* will be added directly to the headers array as "Cookie" headers.
*
* @param Zend_Http_Cookie|string $cookie
* @param string|null $value If "cookie" is a string, this is the cookie value.
*/
public function setCookie($cookie, $value = null)
{
if (!is_null($value)) {
$value = urlencode($value);
}
if (isset($this->Cookiejar)) {
if ($cookie instanceof Zend_Http_Cookie) {
$this->Cookiejar->addCookie($cookie);
} elseif (is_string($cookie) && !is_null($value)) {
if (preg_match("/[=,; \t\r\n\v\f]/", $cookie)) {
throw new Zend_Http_Exception("Cookie name cannot contain these characters: =,; \t\r\n\v\f ({$name})");
}
$cookie = Zend_Http_Cookie::factory("{$cookie}={$value}", $this->uri);
$this->Cookiejar->addCookie($cookie);
}
} else {
parent::setCookie($cookie, $value);
}
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:26,代码来源:Client.php
示例11: testZF5690OverflowingExpiryDate
/**
* Test that cookies with far future expiry date (beyond the 32 bit unsigned int range) are
* not mistakenly marked as 'expired'
*
* @link http://framework.zend.com/issues/browse/ZF-5690
*/
public function testZF5690OverflowingExpiryDate()
{
$expTime = "Sat, 29-Jan-2039 00:54:42 GMT";
$cookie = Zend_Http_Cookie::fromString("foo=bar; domain=.example.com; expires={$expTime}");
$this->assertFalse($cookie->isExpired(), 'Expiry: ' . $cookie->getExpiryTime());
}
开发者ID:travisj,项目名称:zf,代码行数:12,代码来源:CookieTest.php
示例12: setCookie
/**
* Add a cookie to the request. If the client has no Cookie Jar, the cookies
* will be added directly to the headers array as "Cookie" headers.
*
* @param Zend_Http_Cookie|string $cookie
* @param string|null $value If "cookie" is a string, this is the cookie value.
* @return Zend_Http_Client
*/
public function setCookie($cookie, $value = null)
{
if (! class_exists('Zend_Http_Cookie'))
require_once 'Zend/Http/Cookie.php';
if (is_array($cookie)) {
foreach ($cookie as $c => $v) {
if (is_string($c)) {
$this->setCookie($c, $v);
} else {
$this->setCookie($v);
}
}
return $this;
}
if ($value !== null) $value = urlencode($value);
if (isset($this->cookiejar)) {
if ($cookie instanceof Zend_Http_Cookie) {
$this->cookiejar->addCookie($cookie);
} elseif (is_string($cookie) && $value !== null) {
$cookie = Zend_Http_Cookie::fromString("{$cookie}={$value}", $this->uri);
$this->cookiejar->addCookie($cookie);
}
} else {
if ($cookie instanceof Zend_Http_Cookie) {
$name = $cookie->getName();
$value = $cookie->getValue();
$cookie = $name;
}
if (preg_match("/[=,; \t\r\n\013\014]/", $cookie))
throw new Zend_Http_Client_Exception("Cookie name cannot contain these characters: =,; \t\r\n\013\014 ({$cookie})");
$value = addslashes($value);
if (! isset($this->headers['cookie'])) $this->headers['cookie'] = '';
$this->headers['cookie'] .= $cookie . '=' . $value . '; ';
}
return $this;
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:52,代码来源:Client.php
示例13: testMatchPathWithTrailingSlash
/**
* Make sure that paths with trailing slashes are matched as well as paths with no trailing slashes
*/
public function testMatchPathWithTrailingSlash()
{
$jar = new Zend_Http_CookieJar();
$cookies = array(
Zend_Http_Cookie::fromString('foo1=bar1; domain=.example.com; path=/a/b'),
Zend_Http_Cookie::fromString('foo2=bar2; domain=.example.com; path=/a/b/')
);
foreach ($cookies as $cookie) $jar->addCookie($cookie);
$cookies = $jar->getMatchingCookies('http://www.example.com/a/b/file.txt');
$this->assertType('array', $cookies);
$this->assertEquals(2, count($cookies));
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:17,代码来源:CookieJarTest.php
示例14: setCookie
/**
* Add a cookie to the request. If the client has no Cookie Jar, the cookies
* will be added directly to the headers array as "Cookie" headers.
*
* @param Zend_Http_Cookie|string $cookie
* @param string|null $value If "cookie" is a string, this is the cookie value.
* @return Zend_Http_Client
* @throws Zend_Http_Client_Exception
*/
public function setCookie($cookie, $value = null)
{
Zend_Loader::loadClass('Zend_Http_Cookie');
if (is_array($cookie)) {
foreach ($cookie as $c => $v) {
if (is_string($c)) {
$this->setCookie($c, $v);
} else {
$this->setCookie($v);
}
}
return $this;
}
if ($value !== null && $this->config['encodecookies']) {
$value = urlencode($value);
}
if (isset($this->cookiejar)) {
if ($cookie instanceof Zend_Http_Cookie) {
$this->cookiejar->addCookie($cookie);
} elseif (is_string($cookie) && $value !== null) {
$cookie = Zend_Http_Cookie::fromString("{$cookie}={$value}", $this->uri, $this->config['encodecookies']);
$this->cookiejar->addCookie($cookie);
}
} else {
if ($cookie instanceof Zend_Http_Cookie) {
$name = $cookie->getName();
$value = $cookie->getValue();
$cookie = $name;
}
if (preg_match("/[=,; \t\r\n\v\f]/", $cookie)) {
/** @see Zend_Http_Client_Exception */
require_once 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception("Cookie name cannot contain these characters: =,; \t\r\n\v\f ({$cookie})");
}
$value = addslashes($value);
if (!isset($this->headers['cookie'])) {
$this->headers['cookie'] = array('Cookie', '');
}
$this->headers['cookie'][1] .= $cookie . '=' . $value . '; ';
}
return $this;
}
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:51,代码来源:Client.php
示例15: testPregMatchIsQuoted
/**
* @group ZF-10506
*/
public function testPregMatchIsQuoted()
{
$this->assertFalse(Zend_Http_Cookie::matchCookieDomain('foo.bar.com', 'www.foozbar.com'));
}
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:7,代码来源:CookieTest.php
示例16: _matchPath
/**
* Return a subset of a domain-matching cookies that also match a specified path
*
* @param array $dom_array
* @param string $path
* @return array
*/
protected function _matchPath($domains, $path)
{
$ret = array();
foreach ($domains as $dom => $paths_array) {
foreach (array_keys($paths_array) as $cpath) {
if (Zend_Http_Cookie::matchCookiePath($cpath, $path)) {
if (!isset($ret[$dom])) {
$ret[$dom] = array();
}
$ret[$dom][$cpath] = $paths_array[$cpath];
}
}
}
return $ret;
}
开发者ID:bizanto,项目名称:Hooked,代码行数:22,代码来源:CookieJar.php
示例17: setCookie
/**
* Add a cookie to the request. If the client has no Cookie Jar, the cookies
* will be added directly to the headers array as "Cookie" headers.
*
* @param Zend_Http_Cookie|string $cookie
* @param string|null $value If "cookie" is a string, this is the cookie value.
* @return Zend_Http_Client
*/
public function setCookie($cookie, $value = null)
{
if ($value !== null) {
$value = urlencode($value);
}
if (isset($this->Cookiejar)) {
if ($cookie instanceof Zend_Http_Cookie) {
$this->Cookiejar->addCookie($cookie);
} elseif (is_string($cookie) && $value !== null) {
$cookie = Zend_Http_Cookie::factory("{$cookie}={$value}", $this->uri);
$this->Cookiejar->addCookie($cookie);
}
} else {
if ($cookie instanceof Zend_Http_Cookie) {
$cookie = $cookie->getName();
$value = $cookie->getValue();
}
if (preg_match("/[=,; \t\r\n\v\f]/", $cookie)) {
throw new Zend_Http_Client_Exception("Cookie name cannot contain these characters: =,; \t\r\n\v\f ({$name})");
}
$value = urlencode($value);
$this->setHeaders('cookie', "{$cookie}={$value}", false);
}
return $this;
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:33,代码来源:Client.php
注:本文中的Zend_Http_Cookie类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论