Retrieving Session Data
You can use {{ session }}
as a tag pair to access all the data inside your user's session.
{{ session }} {{ message }}{{ /session }}
<s:session> {{ $message }}</s:session>
Welcome to the session.
You can also retrieve single variables with a single tag syntax.
{{ session:message }}
{{-- Using Antlers Blade Components --}}<s:session:message /> {{-- Using session() helper --}}{{ session()->get('message') }}
Setting and Forgetting
You can set data with session:set, flash data with session:flash, forget it with session:forget, and flush the entire session with session:flush.
Checking
You can check if data is set in a session with session:has.
{{ if {session:has key="has_voted"} === true }} You already voted. Thank you!{{ /if }}
@if (session()->has('has_voted') === true) You already voted. Thank you!@endif
Debugging
If you want to peek into the session and check the data, do so with with session:dump or the debug bar.
Aliasing
If you need extra markup around your session data, you can alias a new child array variable.
{{ session as="sesh" }} {{ sesh }} {{ message }} {{ /sesh }}{{ /session }}
{{-- Using the session() helper and PHP --}}@php($sesh = session()->all())