Skip to content

Commit 828efff

Browse files
[10.x] Document session except and only methods (#9230)
* document session except and only methods * Update session.md --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent f3444f1 commit 828efff

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

session.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ If you would like to retrieve all the data in the session, you may use the `all`
144144

145145
$data = $request->session()->all();
146146

147+
<a name="retrieving-a-portion-of-the-session-data"></a>
148+
#### Retrieving a Portion of the Session Data
149+
150+
The `only` and `except` methods may be used to retrieve a subset of the session data:
151+
152+
$data = $request->session()->only(['username', 'email']);
153+
154+
$data = $request->session()->except(['username', 'email']);
155+
147156
<a name="determining-if-an-item-exists-in-the-session"></a>
148157
#### Determining if an Item Exists in the Session
149158

0 commit comments

Comments
 (0)