Category : cookies

I have a Laravel project and a WordPress project into laravel ‘public’ folder. https://www.mysite.it/ (Laravel) https://www.mysite.it/wp/ (WordPress) I can see Laravel cookies in my WordPress project, but cannot see WordPress cookie in Laravel Project. There is a way for get WordPress cookies in a Laravel project? thanks! Sourc..

Read more

I’m trying to delete a specific value from the cookie array called ‘wishlist’. I tried using Cookie::forget(‘wishlist’);. I’m using a destroy method in the controller. The problem is that it deletes the entire cookie array and not just the specified value. destroy() public function destroy($id) { $books = Book::findOrFail($id); $cookie = Cookie::get(‘wishlist’); $cookieArray = explode(‘,’, ..

Read more

I currently have a React Application spawned via CRA running on http://paulsamazinglocalhost.com:3000 package json as follows: "start": "HOST=paulsamazinglocalhost.com PORT=3000 react-scripts start", I’m currently (trying) to talk to a Laravel API running on port 8000 specifically http://api.paulsamazinglocalhost.com:8000 spawned via laravel as follows: php artisan serve –port 8000 –host api.paulsamazinglocalhost.com Now, "what does the Laravel CORS configuration ..

Read more

My application is laravel 8.75.0 in the backend serving apis requests for a react frontend. I am using session to authenticate users, and to store session variables. On production, react is built, and served statically using apache. Links are: http://123.123.123.123/api -> backend laravel routes http://123.123.123.123/dashboard -> react build folder The production really doesn’t use a ..

Read more

I’m trying to send a cookie whose name contains two dots. this is my code $response = Http::withHeaders([ ‘Cookie’ => ‘.cookie.withdots=test-value’ ])->get(‘http://example.com’); now when I send this request to my system on another route and print the cookies dots(.) has transformed to underscores(_) array:1 [ "_cookie_withdots" => "test-value" ] I need them to stay as ..

Read more

we recently upgraded from older Laravel to Laravel 8 and cookies doesn’t seem to work anymore. We have dynamically created links for translating website: <a href="{{ URL::to(‘/translate’) }}/{{ $language->language_code }}"> In this route->function we create a cookie: public function cookie_translate($id){ Cookie::queue(‘translate’, $id, 3000); return Redirect::route(‘index’)->withCookie(‘translate’); } And in AppServiceProvider.php we retreive cookie: if(!empty(Cookie::get(‘translate’))){ $translate = ..

Read more

I’m building an SPA with Angular and Laravel. I’m using Laravel Sanctum for authentication and CSRF-Protection. Currently, I’m sending the GET-Request this.http.get(‘/sanctum/csrf-cookie’).subscribe(); to get a new CSRF-Cookie before every single Request. I think this is a bit too much. How often should I Request a new Cookie? Only when the Cookie is not valid (when i ..

Read more

So, my API(laravel) runs on for example https://api.example.com and on client side, my site runs on http://127.0.0.1:3000. The API sends the following cookie, set-cookie: XSRF-TOKEN=eyJpdiI6IkVRSjcyYzBoVzRTazQ4RWJjK0JSd2c9PSIsInZhbHVlIjoiT20yb3AwZk1HemloaUl2MFZZdkUyUVM3Z3pXc3B0QXpiUEZPUEJIWElJYjRHamtlZ3d5NU5yb3doWmQ4ZXNBb1g0eTFiZXliRlFmWkN1SjVRMVFaM3pXK2x0MTMyK1MwTnp3cVZFSksvaVlJdGdLNGpKZXVrR3lITTRPU2VYNWgiLCJtYWMiOiI0MGU3NmEzYmI2NjY3MTkwNTNlMDQ2ZWRiNjVmNzdmYzA1MTMzOWE0NjA0YzAxYzBjZTczNzI4MDljOThhYTRmIn0%3D; expires=Wed, 30-Sep-2026 06:29:36 GMT; Max-Age=155520000; path=/; samesite=lax However this cookie is not set by the browser as it’s always empty. I make the request as follows: axios.get("https://api.example.com/users") What could be ..

Read more

I am using multiple laravel version like 6.x, 8.x in my local machine. In all my laravel apps I observed that laravel is appending encrypted cookie key name in cookie value. https://github.com/laravel/framework/blob/00fa9c04aed10d68481f5757b89da0e6798f53b3/src/Illuminate/Cookie/CookieValuePrefix.php for example if my cookie name is laravel_session and cookie value is xyz then laravel is adding laravel_sessionv2|xyz in the cookie value after ..

Read more

Can someone please give me the workflow again. I would like my Laravel backend to set a cookie on the client the first time a SPA is requested. I have already tried something. SomeController return response()->json([])->cookie( ‘cart_token’, ‘123abc’, 60 ); When I test it with Postman or Insomnia, it works. But an Axios get request ..

Read more