Last active
December 22, 2019 17:54
-
-
Save moradi-morteza/b442aad0bc147b44009f72c3daf579ec to your computer and use it in GitHub Desktop.
[session] #LaravelT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set session---------------------- | |
session()->put('name','morteza');// or | |
session(['name'=>'hamid','age'=>23]); | |
// to get session | |
echo session()->get('name'); //or | |
echo session('name','default'); | |
// check session--------------------- | |
session('name',null); | |
session()->has('name') // return a boolean and check key and value -> so reutrn false | |
session('name',null); | |
session()->exists('name') // check justn key -> so it retrun true | |
// other methods---------------------- | |
session()->all(); // save data like previous url for redirect | |
// delete session--------------------- | |
$name =session()->pull('name'); // remove name from session and save value of it in $name | |
session()->forget('name'); // remove from session and not save or return any thing | |
session()->flush(); // remove all sessions | |
// flash session | |
// flash values just one save in old and if you reload page it remove - it is very good for show message | |
session()->flash('name','morteza'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment