You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/http/cookies.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ composer require leafs/cookie
24
24
25
25
Since cookies are sent to the client's browser as part of the response, Leaf provides a direct way to set cookies on your response. You can directly call `withCookie()` on your response object to set a cookie.
26
26
27
-
```php
27
+
```php:no-line-numbers
28
28
response()->withCookie('name', 'Fullname');
29
29
```
30
30
@@ -70,15 +70,15 @@ The `set()` method allows you to set cookies with more advanced options like exp
70
70
71
71
When you send cookies to the client, they are stored in your users' browser and automatically sent back to your app on every request. You can read these cookies using the `get()` method.
72
72
73
-
```php
73
+
```php:no-line-numbers
74
74
$name = cookie()->get('name');
75
75
```
76
76
77
77
This method takes in the cookie name and returns the cookie value. If the cookie doesn't exist, it returns `null`.
78
78
79
79
You can also get all cookies at once using the `all()` method.
80
80
81
-
```php
81
+
```php:no-line-numbers
82
82
$cookies = cookie()->all();
83
83
```
84
84
@@ -109,6 +109,6 @@ cookie()->delete('name');
109
109
110
110
You may also choose to delete all your cookies, for instance if you detect an authentication or authorization breech in your application. You can do this using the `deleteAll()` method on Leaf cookies.
0 commit comments