how to add data in session in php

session is use to track the activity of user on browser and apart from that it is also use to send and receive data from one page of php to another how to add data in session in php page.
how to add data in session in phpexpoundsofttechsolution Install node js on Go Daddy Shared hosting. How to use session in php ?
Step 1 Firstly load the session on the page where you want to use it. Here we use session to pass variable data from one controller to another controller .
$session = session();
Step 2 Now set the data in session what you want to pass.
 $_SESSION['name_in_session']  = "user1";
In the above code “user1” is the name of user which we will pass to another page. And ‘name_in_session’ is the key name which store the data. Notice that you can set any name but it should be same on both page. Now move toward the another page or controller where you want to use it. and to use session repeat the Step 1 on that page .

Step 3 Get the name of session in variable , where you want to use it.
$current_user = session()->get('name_in_session'); 

In the above line we get the user name and assign it to variable $current_user.
That’s it