本文整理汇总了PHP中Request::cookie方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::cookie方法的具体用法?PHP Request::cookie怎么用?PHP Request::cookie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request::cookie方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
public static function initialize()
{
if (self::$initialized) {
return;
}
self::$initialized = true;
try {
// Initialize local session
Session::init();
if (!empty($_GET['logout'])) {
self::destroy();
Session::init();
}
if (!Session::userIsLoggedIn() && Request::cookie('remember_me')) {
if (!LoginModel::loginWithCookie(Request::cookie('remember_me'))) {
LoginModel::deleteCookie();
}
}
$currentUrl = $_SERVER['REQUEST_URI'];
$end = strpos($currentUrl, '?');
if ($end === false) {
$end = strpos($currentUrl, '#');
}
if ($end !== false) {
$currentUrl = substr($currentUrl, 0, $end);
}
// Initialize Facebook session
/*self::$facebookSession = new FacebookSessionWrapper(
Tools::getBaseUrl() . $currentUrl,
Tools::getBaseUrl() . '/logout/'
);*/
} catch (\Exception $ex) {
}
}
示例2: getCompleteTask
function getCompleteTask()
{
$data = Request::cookie('auth');
$model = new siteUserTaskModel();
$tasks = $model->where(array('user' => $data['login'], 'status' => 0))->sort('date', -1)->fetchAll();
return $tasks;
}
示例3: _send_message
/**
* Sends the HTTP message [Request] to a remote server and processes
* the response.
*
* @param Request $request request to send
* @param Response $request response to send
* @return Response
*/
public function _send_message(Request $request, Response $response)
{
$http_method_mapping = array(HTTP_Request::GET => HTTPRequest::METH_GET, HTTP_Request::HEAD => HTTPRequest::METH_HEAD, HTTP_Request::POST => HTTPRequest::METH_POST, HTTP_Request::PUT => HTTPRequest::METH_PUT, HTTP_Request::DELETE => HTTPRequest::METH_DELETE, HTTP_Request::OPTIONS => HTTPRequest::METH_OPTIONS, HTTP_Request::TRACE => HTTPRequest::METH_TRACE, HTTP_Request::CONNECT => HTTPRequest::METH_CONNECT);
// Create an http request object
$http_request = new HTTPRequest($request->uri(), $http_method_mapping[$request->method()]);
if ($this->_options) {
// Set custom options
$http_request->setOptions($this->_options);
}
// Set headers
$http_request->setHeaders($request->headers()->getArrayCopy());
// Set cookies
$http_request->setCookies($request->cookie());
// Set query data (?foo=bar&bar=foo)
$http_request->setQueryData($request->query());
// Set the body
if ($request->method() == HTTP_Request::PUT) {
$http_request->addPutData($request->body());
} else {
$http_request->setBody($request->body());
}
try {
$http_request->send();
} catch (HTTPRequestException $e) {
throw new Request_Exception($e->getMessage());
} catch (HTTPMalformedHeaderException $e) {
throw new Request_Exception($e->getMessage());
} catch (HTTPEncodingException $e) {
throw new Request_Exception($e->getMessage());
}
// Build the response
$response->status($http_request->getResponseCode())->headers($http_request->getResponseHeader())->cookie($http_request->getResponseCookies())->body($http_request->getResponseBody());
return $response;
}
示例4: Logout
public static function Logout()
{
setcookie('userid', '0', time() + 10, '/');
UserModel::update(['hash' => ''])->where('hash = ?', [0 => Request::cookie('userid')]);
self::$login = 'Гость';
self::$id = 0;
self::$company_id = 0;
}
示例5: unsetCart
public static function unsetCart()
{
$key = \Request::cookie('shoppingCart');
$cart = \App\Cart::where('key', $key)->first();
$cookie = \Cookie::forget('shoppingCart');
$cart->delete();
return $cookie;
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$cookie = \Request::cookie('remember_token');
if ($cookie && !\Session::has('User')) {
$this->authService->autoLoginCheck();
}
return $next($request);
}
示例7: _send_message
/**
* Sends the HTTP message [Request] to a remote server and processes
* the response.
*
* @param Request request to send
* @return Response
*/
public function _send_message(Request $request)
{
// Response headers
$response_headers = array();
// Set the request method
$options[CURLOPT_CUSTOMREQUEST] = $request->method();
// Set the request body. This is perfectly legal in CURL even
// if using a request other than POST. PUT does support this method
// and DOES NOT require writing data to disk before putting it, if
// reading the PHP docs you may have got that impression. SdF
$options[CURLOPT_POSTFIELDS] = $request->body();
// Process headers
if ($headers = $request->headers()) {
$http_headers = array();
foreach ($headers as $key => $value) {
$http_headers[] = $key . ': ' . $value;
}
$options[CURLOPT_HTTPHEADER] = $http_headers;
}
// Process cookies
if ($cookies = $request->cookie()) {
$options[CURLOPT_COOKIE] = http_build_query($cookies, NULL, '; ');
}
// Create response
$response = $request->create_response();
$response_header = $response->headers();
// Implement the standard parsing parameters
$options[CURLOPT_HEADERFUNCTION] = array($response_header, 'parse_header_string');
$this->_options[CURLOPT_RETURNTRANSFER] = TRUE;
$this->_options[CURLOPT_HEADER] = FALSE;
// Apply any additional options set to
$options += $this->_options;
$uri = $request->uri();
if ($query = $request->query()) {
$uri .= '?' . http_build_query($query, NULL, '&');
}
// Open a new remote connection
$curl = curl_init($uri);
// Set connection options
if (!curl_setopt_array($curl, $options)) {
throw new Request_Exception('Failed to set CURL options, check CURL documentation: :url', array(':url' => 'http://php.net/curl_setopt_array'));
}
// Get the response body
$body = curl_exec($curl);
// Get the response information
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($body === FALSE) {
$error = curl_error($curl);
}
// Close the connection
curl_close($curl);
if (isset($error)) {
throw new Request_Exception('Error fetching remote :url [ status :code ] :error', array(':url' => $request->url(), ':code' => $code, ':error' => $error));
}
$response->status($code)->body($body);
return $response;
}
示例8: __construct
function __construct()
{
Session::init();
Auth::checkSessionConcurrency();
if (!Session::userIsLoggedIn() && Request::cookie('remember_me')) {
Redirect::to("login/loginWithCookie");
}
$this->view = new View();
}
示例9: loginWithCookie
public function loginWithCookie()
{
$success = LoginModel::loginWithCookie(Request::cookie('remember_me'));
if ($success) {
Redirect::to('dashboard/index');
} else {
LoginModel::deleteCookie();
Redirect::to('login/index');
}
}
示例10: logout
public function logout()
{
$this->authService->unsetUser();
$token = \Request::cookie('remember_token');
if ($token) {
$this->authService->deleteOldRememberToken($token);
$this->authService->deleteRememberTokenCookie();
}
return \Redirect::to('login');
}
示例11: __construct
/**
* Construct the (base) controller. This happens when a real controller is constructed, like in
* the constructor of IndexController when it says: parent::__construct();
*/
function __construct()
{
// always initialize a session
Session::init();
// user is not logged in but has remember-me-cookie ? then try to login with cookie ("remember me" feature)
if (!Session::userIsLoggedIn() and Request::cookie('remember_me')) {
header('location: ' . Config::get('URL') . 'login/loginWithCookie');
}
// create a view object to be able to use it inside a controller, like $this->View->render();
$this->View = new View();
}
示例12: autoLoginCheck
public function autoLoginCheck()
{
$token = \Request::cookie('remember_token');
if ($user = $this->userService->getByToken($token)) {
$this->deleteOldRememberToken($token);
$remember = true;
$this->login($user, $remember);
return true;
}
return false;
}
示例13: __construct
/**
* Construct the (base) controller. This happens when a real controller is constructed, like in
* the constructor of IndexController when it says: parent::__construct();
*/
function __construct()
{
// always initialize a session
Session::init();
// user is not logged in but has remember-me-cookie ? then try to login with cookie ("remember me" feature)
if (!Session::userIsLoggedIn() and Request::cookie('remember_me')) {
header('location: ' . Config::get('URL') . 'login/loginWithCookie');
}
// create a view object to be able to use it inside a controller, like $this->View->render();
$this->View = new View();
$this->Must = new MustView(array('loader' => new Mustache_Loader_FilesystemLoader(Config::get('PATH_VIEW'), ['extension' => '.html']), 'partials_loader' => new Mustache_Loader_FilesystemLoader(Config::get('PATH_PARTIAL'), ['extension' => '.html']), 'cache' => Config::get('PATH_TEMPLATES_CACHE'), 'logger' => new MustacheLogger(Mustache_Logger::DEBUG)));
}
示例14: loginWithCookie
/**
* Login with cookie
*/
public function loginWithCookie()
{
// run the loginWithCookie() method in the login-model, put the result in $login_successful (true or false)
$login_successful = LoginModel::loginWithCookie(Request::cookie('remember_me'));
// if login successful, redirect to dashboard/index ...
if ($login_successful) {
Redirect::to('dashboard/index');
} else {
// if not, delete cookie (outdated? attack?) and route user to login form to prevent infinite login loops
LoginModel::deleteCookie();
Redirect::to('login/index');
}
}
示例15: init
public static function init()
{
if (ini_get('magic_quotes_gpc')) {
self::$get = $_GET;
self::$post = $_POST;
} else {
self::$get = $_GET = self::addSlashes($_GET);
self::$post = $_POST = self::addSlashes($_POST);
}
self::$cookie = $_COOKIE;
self::$file = $_FILES;
self::$method = $_SERVER['REQUEST_METHOD'];
}