本文整理汇总了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);
}