简体   繁体   中英

How to use session in public direcory in laravel

I set session for getting name of the user when he/she logged-in

but when I want to echo it in public directory I can not echo and I don't know can I declare

In controller

session(['sessionName' => 'Karim']);

In public

echo $_SESSION['CKFinder_UserRole']

It's give me a fatal error to:

undefined variable

Please help me. Thanks

You can do like this, In Controller,

return back()->with('name','Hello');

in view,

{{ Session::get('name') }}

Hope this helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM