1
Q

Where is your application’s session configuration file stored?

A

It is stored at config/session.php

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Laravel’s default session driver?

A

database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which are two primary ways of working with session data in Laravel?

A

The global session helper and via a Request instance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can you retrieve all the data in the session?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can you retrieve a subset of the session data?

A

Either by using the only method, which will only fetch the requested items, or by using the except method, which will fetch everything except the listed items.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you determine if an item is present and not null in the session?

A

->session()->has('example')

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

If you want to check if an item is present in the session, even if it is null, which method should you use?

A

->session()->exists('example')

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

To determine if an item is not present in the session, what do you need to do?

A

->session()->missing('example')

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can you add a new value onto a session value that is an array?

A

->session()->push('user.teams', 'developers');

This would add developers as a team to the users table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which method will retrieve and delete an item from the session in a single statement?

A

->session()->pull('example')

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can you count an integer up or down within your session data?

A
$request->session()->increment('count');

$request->session()->increment('count', $incrementBy = 2);

$request->session()->decrement('count');

$request->session()->decrement('count', $decrementBy = 2);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you store an item in the session that is only going to be there for the next request?

A

->session()->flash('status', 'Task was successful!');

After being accessed once flashed items will be deleted from the session. Flash data is primarily useful for short-lived status messages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which methods let you persist your flash data for an additional request?

A
->session()->reflash(); for everything or
->session()->keep[('example', 'exampletwo']); for specific items
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can you remove one or multiple items from the session?

A
->session()->forget('example');
->session()->forget(['example', 'exampletwo']);

Or to just remove everything from the session:
->session()->flush();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How can you regenerate the session ID and how can you do that plus remove all data from the session in a single statement?

A

To just regenerate the session ID use ->session()->regenerate();
If you also want to remove all data from the session while also regenerating the session ID, use ->session()->invalidate();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly