Skip to content

The cookie not saved after server respond with {"status": "ok"} #62

Open
@szotyi41

Description

@szotyi41

Maybe I found an issue. I used this package in our older project and everything worked.
In our new project, the popup came back constantly and when I checked the cookie is saved at the Application tab, it is not.

I started to find differences, and I found the domain was different.
It is saved to .env in the same way, but older project (mvs) has no domain parameter in Set-Cookie.
But the newer project it has with https://.
Now I hacked the configuration file like this and it is working.

    'url' => [
        'domain' => str_replace('https://', '', env('APP_URL', 'http://localhost:8000')),
        'middleware' => [],
        'prefix' => 'cookie-consent',
    ],

    /*
    |--------------------------------------------------------------------------
    | Consent cookie configuration
    |--------------------------------------------------------------------------
    |
    | In order to keep track of the user's preferences, this package stores
    | an anonymized cookie. You do not need to register this cookie in the
    | package's cookie manager as it is done automatically (under "essentials").
    |
    | The duration parameter represents the cookie's lifetime in minutes.
    |
    | The domain parameter, when defined, determines the cookie's activity domain.
    | For multiple sub-domains, prefix your domain with "." (eg: ".mydomain.com").
    |
    */

    'cookie' => [
        'name' => Str::slug(env('APP_NAME', 'laravel'), '_').'_cookie_consent',
        'duration' => (60 * 24 * 365),
        'domain' => str_replace('https://', '', env('APP_URL', 'http://localhost:8000')),
    ],
Képernyőfotó 2024-09-09 - 12 47 03

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions