Skip to content
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

Pass encrypted Laravel session cookie #658

Open
NickHoner opened this issue Oct 28, 2024 · 0 comments
Open

Pass encrypted Laravel session cookie #658

NickHoner opened this issue Oct 28, 2024 · 0 comments

Comments

@NickHoner
Copy link

I have a site in Laravel and I would like to pass the currently authenticated user to Chrome to generate a PDF of a page that is behind authentication. This works fine if I disable Laravel from encrypting the session cookie, but I can't seem to figure out how to get the correct encrypted value to pass to Chrome:

Fails to get past auth:

$page->setCookies([
    Cookie::create(config('session.cookie'), Crypt::encrypt(session()->getId()), [
        'domain' => $domain,
        'expires' => time() + 3600, // expires in 1 hour
    ])
])->await();

Works

// AppServiceProvider:
EncryptCookies::except(['laravel_session']);
// 

$page->setCookies([
    Cookie::create(config('session.cookie'), session()->getId(), [
        'domain' => $domain,
        'expires' => time() + 3600, // expires in 1 hour
    ])
])->await();

Can anyone give me any pointers as to how Laravel encrypts the cookie?

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

No branches or pull requests

1 participant