當前位置: 首頁>>代碼示例>>PHP>>正文


PHP setXsrfCookie函數代碼示例

本文整理匯總了PHP中setXsrfCookie函數的典型用法代碼示例。如果您正苦於以下問題:PHP setXsrfCookie函數的具體用法?PHP setXsrfCookie怎麽用?PHP setXsrfCookie使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了setXsrfCookie函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: connectToEncryptedMySql

 //grab the mySQL connection
 $pdo = connectToEncryptedMySql("/etc/apache2/capstone-mysql/timecrunch.ini");
 //if the user session is empty, the user is not logged in, throw an exception
 if (empty($_SESSION["user"]) === true) {
     setXsrfCookie("/");
     throw new RuntimeException("Please log-in or sign up", 401);
 }
 //determine which HTTP method was used
 $method = array_key_exists("HTTP_X_HTTP_METHOD", $_SERVER) ? $_SERVER["HTTP_X_HTTP_METHOD"] : $_SERVER["REQUEST_METHOD"];
 $reply->method = $method;
 //sanitize the id
 $id = filter_input(INPUT_GET, "id", FILTER_VALIDATE_INT);
 //Handle REST calls
 if ($method === "GET") {
     //Set XSRF cookie
     setXsrfCookie("/");
     //Get Request based on given field
     if (empty($id) === false) {
         $request = Request::getRequestByRequestId($pdo, $id);
         if ($request !== null) {
             $reply->data = $request;
         }
     } else {
         $request = Request::getAllRequests($pdo);
         if ($request !== null) {
             $reply->data = $request;
         }
     }
 } elseif ($method === "PUT" || $method === "POST") {
     $requestContent = file_get_contents("php://input");
     $requestObject = json_decode($requestContent);
開發者ID:CreativeCorrie,項目名稱:time-crunchers,代碼行數:31,代碼來源:index.php

示例2: dirname

<?php

require_once dirname(__DIR__) . "/lib/xsrf.php";
/**
 * simple controller simply for handing out an xsrf token when booting the mobile app
 *
 * @author Bradley Brown tall.white.ninja@gmail.com
 */
if (session_status() !== PHP_SESSION_ACTIVE) {
    session_start();
}
setXsrfCookie('/');
開發者ID:brbrown59,項目名稱:bread-basket,代碼行數:12,代碼來源:landing-controller.php

示例3: session_start

 **/
// verify the session, start if not active
if (session_status() !== PHP_SESSION_ACTIVE) {
    session_start();
}
$reply = new stdClass();
$reply->status = 200;
$reply->data = null;
try {
    $pdo = connectToEncryptedMySQL("/etc/apache2/encrypted-config/ng-abq-dev.ini");
    $method = array_key_exists("HTTP_X_HTTP_METHOD", $_SERVER) ? $_SERVER["HTTP_X_HTTP_METHOD"] : $_SERVER["REQUEST_METHOD"];
    $id = filter_input(INPUT_GET, "id", FILTER_VALIDATE_INT);
    $profileId = filter_input(INPUT_GET, "profileId", FILTER_VALIDATE_INT);
    if ($method === "GET") {
        //set XSRF cookie
        setXsrfCookie();
        if (empty($id) === false) {
            $event = Beta\Event::getEventByEventId($pdo, $id);
            if ($event !== null) {
                $reply->data = $event;
            }
        } else {
            if (empty($profileId) === false) {
                $events = Beta\Event::getEventByEventProfileId($pdo, $profileId)->toArray();
                if ($events !== null) {
                    $reply->data = $events;
                }
            } else {
                $events = Beta\Event::getAllEvents($pdo)->toArray();
                if ($events !== null) {
                    $reply->data = $events;
開發者ID:ng-abq,項目名稱:ng-abq,代碼行數:31,代碼來源:index.php


注:本文中的setXsrfCookie函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。