php - Laravel My session is not available in other controller function
Get the solution ↓↓↓I have a issue , I am creating session but when we access session in another controller,
so the session variable not found there
Route
Route::get('entry1', 'TestController@entry1');
Route::get('entry2', 'TestController@entry2');
Controller function
public function entry1(Request $request)
{
Session::put('username', 'adminTest');
echo Session::get('username');
}
public function entry2(Request $request)
{
echo Session::get('username');
}
Answer
Solution:
You can use like this :
To set value in session :
Session(['sessionId' => $sessionId]);
To get value from session
$sessionId = Session('sessionId');
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to undefined function mysqli_connect()
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.