Forem

Muhamad Jamil
Muhamad Jamil

Posted on

Resolving problem with 2 csrf tokens in same domain laravel

if you have 2 apps on same domain like

https://somesite.com/someapp-1
https://somesite.com/someapp-2
Enter fullscreen mode Exit fullscreen mode

The CSRF token will competing each other, and it happen today in my office, the easy way to fix it is setting your cookies.php file

search some settings called path in cookies.php

    /*
    |--------------------------------------------------------------------------
    | Session Cookie Path
    |--------------------------------------------------------------------------
    |
    | The session cookie path determines the path for which the cookie will
    | be regarded as available. Typically, this will be the root path of
    | your application but you are free to change this when necessary.
    |
    */

    'path' => '/',


Enter fullscreen mode Exit fullscreen mode

and change it to your app path like

'path' => '/someapp-1/'

or you can use .env too

thanks for reading, also thanks for this stackoverflow questions

https://stackoverflow.com/questions/68468526/is-it-possible-to-rename-the-xsrf-token-cookie-that-laravel-is-creating

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

đź‘‹ Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay