Support the ongoing development of Laravel.io →
posted 9 years ago
Session
Last updated 2 years ago.
0

instead of use Illuminate\Support\Facades\Session; add use Session

0

Use the Session class in the root namespace.

I.e.

public function createSession($username)
{
    \Session::put('username', $username); // Note the backslash to indicate the root class path.
}

The use Session; method should also work.

If this still doesn't work you can use the session() helper function which returns a session instance:

public function createSession($username)
{
   session()->put('username', $username);

   var_dump( session()->get('username') ); // outputs the value of $username
}
Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.