Consuming Cookies between subdomains

Published 1 week ago by Tarasovych

I have sub1.example.com (port 80 - Laravel app) and sub2.example.com (port 8080 - Vue app). Both on local now. I want to set a Cookie on sub1.example.com and send it to sub2.example.com. So I set Cookie parameter Domain='.example.com'. Why sub2.example.com can't receive Cookie? There is even no Set-Cookie header. What am I doing worng? According to this answer, I have correct Domain parameter. Thank you for help!

Cronix
Cronix
1 week ago (398,210 XP)

You mentioned using Vue. Is your session config set like this, which is the default?

    /*
    |--------------------------------------------------------------------------
    | HTTP Access Only
    |--------------------------------------------------------------------------
    |
    | Setting this value to true will prevent JavaScript from accessing the
    | value of the cookie and the cookie will only be accessible through
    | the HTTP protocol. You are free to modify this option if needed.
    |
    */

    'http_only' => true,

notice the note about it.

Tarasovych

@Cronix I have it as false. By the way I can receive Cookie while using Postman or Insomnia. Vue still doesn't accept. One time I moved Vue to port 81, changed Vue host to be the same as sub1.example.com and I've received Set-Cookie header, but Cookie actually wasn't set.

Tarasovych

Any suggestions?

Please sign in or create an account to participate in this conversation.