1 / 6

laravel sessions

Here learn about http session. All http driven application are stateless. Session provide a way to store information about the user across multiple requests. Laravel provides various drivers like file, cookies, array and database to handle session data. By default file driver is used because it is lightweight session can be configured using its configuration file.

ducathub
Download Presentation

laravel sessions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. WELCOME TO DUCAT INDIA Laravel Sessions

  2. Title Lorem Ipsum

  3. Laravel provides various drivers like file, cookies, array and database to handle session data. By default file driver is used because it is lightweight session can be configured using its configuration file. So, let’s see the session configuration file. • – Open the visual studio and go inside the config directory and in config folder open “session.php” file. Let’s see how you can use a session in Laravel 8. • – For this create new controller. So switch to command prompt and run the command as-: Php artisan make: controller SessionController • And then press enter and controller created successfully. • Now run the application so write- Php artisan serve

  4. Now go to project i.e. visual studio and open app> Http> Controllers> SessionController.php file. Inside file create the controller and then inside it create a function for access the system data. < ? php Namespace App\Http\Controllers; Use Illuminate\Http\Request; Class SessionController extends Controller { Public function getSessionData(Request $request) { } Put if condition in function. Inside if condition just gives session value. < ? php Namespace App\Http\Controllers; Use Illuminate\Http\Request; Class SessionController extends Controller { Public function getSessionData(Request $request) { If ($request->session () ->has (‘name’)) { Echo $request->session () ->get(’name’) } }

  5. Let’s get session method to retrieve data from session by its key name. If session case is not present then just return a message. So write further else () with echo ()-: < ? php Namespace App\Http\Controllers; Use Illuminate\Http\Request; Class SessionController extends Controller { Public function getSessionData(Request $request) { If ($request->session () ->has (‘name’)) { Echo $request->session () ->get(’name’) } ……..Read More (https://tutorials.ducatindia.com/php/laravel-sessions/)

  6. THANK YOU CONTACT:- 70-70-90-50-90 www.ducatindia.com

More Related