I recently ran into a problem where I had a suite of applications hosted on a set of subdomains that all needed to be able to share a single cookie. Any cookies other than the shared cookie needed to stay specific to their subdomain, but this one shared cookie needed to be accessible to any of them. I also wanted to accomplish this using Laravel's Cookie
facade.
The Problem
To accomplish this, there were two issues to solve.
- All cookies created by the Laravel framework are encrypted by default. (link)
- I needed to figure out how to set a domain on the shared cookie that was different than the domain it was being set from.
Setting Non-Encrypted Cookies
In Laravel 5.1, a feature was added which allows you to add a list of cookie names that should not be encrypted to the EncryptCookies
Middleware under the $except
array. Check out [the docs](http://laravel.com/docs/5.1/responses#attaching-cookies