Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot access session variables in Laravel 4

My routes:

Route::group(array("namespace" => "languages"),function(){
   Route::resource("languagesService", "languageServiceController");
   Route::resource("languages","languageController");
});

languageservicecontroller and languagecontroller are in subfolder languages.

During login attempt i saved username and password in

Session::put('username', $user['username']);
Session::put('password', $user['password']);

But when i try to retrieve from languageController

$username = Session::get('username');
$password = Session::get('password');

i am getting following error

"Class 'languages\Session' not found" .

like image 913
uma Avatar asked Jan 30 '26 03:01

uma


1 Answers

You are trying to access the Session class from a namespace where the Session class does not exist.

Try the following:

\Session::get('password')

OR

Include Session class at the top of your file.

<?php namespace languages;

use Session;


class languageServiceController
{

}
like image 82
Anam Avatar answered Feb 02 '26 12:02

Anam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!