8000 "Cannot set session ID after the session has started" when generating csrf token within Behat test · Issue #16594 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

"Cannot set session ID after the session has started" when generating csrf token within Behat test #16594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
toby-griffiths opened this issue Nov 18, 2015 · 2 comments

Comments

@toby-griffiths
Copy link
Contributor

I'm trying to test that a user with the wrong permissions sees the correct response when visting a page that has a csrf token in the path.

I've added a Behat context step to create a csrf token using the 'security.csrf.token_manager', however then visit the page with this token in the path, I get a "Cannot set session ID after the session has started" 500 error.

Can anyone advise what I'm doing wrong, or how I work around this, please?

    /**
     * @When /^I go to the application admin archive page for "(?P<status>[^"]*)" application (?P<number>\d+) with a valid token$/
     *
     * @param string $status
     * @param int    $number
     */
    public function iGoToTheApplicationAdminArchivePageForApplicationWithAValidToken($status, $number)
    {
        $tokenManager = $this->kernel->getContainer()->get('security.csrf.token_manager');
        $token        = $tokenManager->getToken(ApplicationAdminController::CSRF_ARCHIVE);
        var_dump($token);

        $this->visitAdminPage('archive', $status, $number, ['token' => $token]);
    }
@Tobion
Copy link
Contributor
Tobion commented Nov 18, 2015

Duplicate of #13450

@Tobion Tobion closed this as completed Nov 18, 2015
@toby-griffiths
Copy link
Contributor Author

Thanks for the info 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0