本文整理匯總了PHP中Guzzle\Http\Message\RequestInterface::getCookie方法的典型用法代碼示例。如果您正苦於以下問題:PHP RequestInterface::getCookie方法的具體用法?PHP RequestInterface::getCookie怎麽用?PHP RequestInterface::getCookie使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Guzzle\Http\Message\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::getCookie方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onOpen
public function onOpen(ConnectionInterface $from, RequestInterface $request = null)
{
if (empty($request)) {
$resp = new Response(400);
$from->send((string) $resp);
$from->close();
return;
}
// Session management
$saveHandler = $this->_handler;
$id = $request->getCookie(ini_get('session.name'));
if (empty($id)) {
$id = sha1(uniqid() . mt_rand());
}
// Crappy workaround for sessions - don't know why they are not saved
// @see https://github.com/ratchetphp/Ratchet/blob/master/src/Ratchet/Session/SessionProvider.php
if (isset($this->sessions[$id])) {
$from->Session = $this->sessions[$id];
} else {
$from->Session = new Session(new VirtualSessionStorage($saveHandler, $id, $this->_serializer));
$this->sessions[$id] = $from->Session;
}
if (ini_get('session.auto_start')) {
$from->Session->start();
}
$this->onRequest($from, $request);
}
示例2: onOpen
/**
* {@inheritdoc}
*/
public function onOpen(ConnectionInterface $conn, RequestInterface $request = null)
{
if (null === $request || null === ($id = $request->getCookie(ini_get('session.name')))) {
$saveHandler = $this->_null;
$id = '';
} else {
$saveHandler = $this->_handler;
}
$conn->Session = new Session(new VirtualSessionStorage($saveHandler, $id, $this->_serializer));
if (ini_get('session.auto_start')) {
$conn->Session->start();
}
return $this->_app->onOpen($conn, $request);
}
示例3: onRequest
protected function onRequest(GuzzleRequest $request)
{
if (null === ($id = $request->getCookie(ini_get('session.name')))) {
$saveHandler = new NullSessionHandler();
$id = '';
} else {
$saveHandler = $this->saveHandler;
}
$serialClass = "Ratchet\\Session\\Serialize\\{$this->toClassCase(ini_get('session.serialize_handler'))}Handler";
// awesome/terrible hack, eh?
if (!class_exists($serialClass)) {
throw new \RuntimeException('Unable to parse session serialize handler');
}
$serializer = new $serialClass();
$this->session = new Session(new VirtualSessionStorage($saveHandler, $id, $serializer));
if (ini_get('session.auto_start')) {
$this->session->start();
}
}
示例4: getCookie
/**
* Get a cookie value by name
*
* @param string $name Cookie to retrieve
*
* @return null|string
*/
public function getCookie($name)
{
return $this->wrapped->getCookie($name);
}