Support the ongoing development of Laravel.io →
posted 10 years ago
Requests

Hello Everyone I am new to the laravel and working with laravel is quite fun... I have a query. instead of writind in words i would like to write the code as follows:-

Route::get('cookie_create',function(){ $cookie = Cookie::make('fname','varun',30); return Redirect::to('http://www.yahoo.com')->withCookie($cookie); });

Route::get('cookie_get',function(){ $cookie = Cookie::get('fname','no cookie'); return $cookie; });

Route::get('cookie_delete',function(){ Cookie::forget('fname'); return 'cookie has bee deleted'; });

Now when i am accessing the cookie_delete path the cookies are not deleting... It is not showing the default value.Please let me know where i am wrong..

Last updated 2 years ago.
0

You need to return Response

Route::get('cookie_delete',function(){
    $cookie = Cookie::forget('fname');

    return Response::make('cookie has bee deleted')->withCookie($cookie);
});

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.