Skip to content

Session is always empty #107

Description

@top-challenger

Hi.
I am using this Slim\Extras\Middleware\CsrfGuard.php
But I always get this error. Invalid or missing CSRF token.

if (! isset($_SESSION[$this->key])) {
      $_SESSION[$this->key] = sha1(serialize($_SERVER) . rand(0, 0xffffffff));
}
$token = $_SESSION[$this->key];
$userToken = $this->app->request()->post($this->key);
if (isset($userToken) && $token !== $userToken) {
        $this->app->halt(400, 'Invalid or missing CSRF token.');
}

I have checked slim csrf_token so I can get successfully but I always go into in this condition.
if (! isset($_SESSION[$this->key]))
Session is always empty I think.
How can I fix this?
I will appreciate any other's help.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions