Cookie
What is Cookie?

Cookie is also similar to session, session is save data in file but cookie save data in txt file that store our system on window folderRemember me for user login detail is best example for creating cookies

Full Code to Create and Display Cookies


Route
Route::get('/entry1', 'HomeController@entry1');
Route::get('/entry2', 'HomeController@entry2');

Controller
<?php
namespace AppHttpControllers;

use IlluminateHttpRequest;
use IlluminateHttpResponse;
use AppHttpRequests;
use AppHttpControllersController;

class HomeController extends Controller
{
public function entry1(Request $request){
$minutes = 1;
$response = new Response();
$response->withCookie(cookie('username', 'shishirphpdeveloper', $minutes));
return $response;
}
public function entry2(Request $request){
$value = $request->cookie('username');
echo $value;
}

}

 


Previous
Next