File tree 3 files changed +23
-3
lines changed
3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 121
121
'path ' => '/ ' ,
122
122
'domain ' => null ,
123
123
'driver ' => 'file ' ,
124
- 'files ' => __DIR__ . '/sessions ' ,
124
+ 'files ' => __DIR__ . '/../ sessions ' ,
125
125
'lifetime ' => 120 ,
126
126
'expire_on_close ' => false ,
127
127
]
Original file line number Diff line number Diff line change 18
18
use Illuminate \Http \Request ;
19
19
use Illuminate \Pipeline \Pipeline ;
20
20
use Illuminate \Session \SessionManager ;
21
+ use Symfony \Component \HttpFoundation \Cookie ;
21
22
22
23
$ container = App::getInstance ();
23
24
160
161
161
162
// Global middlewares
162
163
$ globalMiddleware = [
163
- \App \Middleware \StartSession::class,
164
164
];
165
165
166
166
// Array middlewares
180
180
// Create a request from server variables
181
181
$ request = Request::capture ();
182
182
183
+ // In order to maintain the session between requests, we need to populate the
184
+ // session ID from the supplied cookie
185
+ $ cookieName = $ container ['session ' ]->getName ();
186
+
187
+ if (isset ($ _COOKIE [$ cookieName ])) {
188
+ if ($ sessionId = $ _COOKIE [$ cookieName ]) {
189
+ $ container ['session ' ]->setId ($ sessionId );
190
+ }
191
+ }
192
+
193
+ // Boot the session
194
+ $ container ['session ' ]->start ();
195
+
183
196
// Dispatching the request:
184
197
// When it comes to dispatching the request, you have two options:
185
198
// a) you either send the request directly through the router
197
210
return $ router ->dispatch ($ request );
198
211
});
199
212
213
+ $ response ->headers ->setCookie (new Cookie (
214
+ $ container ['session ' ]->getName (), $ container ['session ' ]->getId (),
215
+ ));
216
+
217
+ $ container ['session ' ]->save ();
218
+
200
219
// Send the response back to the browser
201
220
$ response ->send ();
202
221
222
+ // Create your user
203
223
// User::create([
204
224
// 'email' => 'admin',
205
225
// 'name' => 'admin',
Original file line number Diff line number Diff line change 18
18
19
19
$ router ->group (['middleware ' => 'auth ' ], function (Router $ router ) {
20
20
$ router ->get ('/ ' , function () {
21
- return 'hello world ! ' ;
21
+ return 'hello ' . \App:: getInstance ()[ ' auth ' ]-> user ()-> name . ' ! ' ;
22
22
});
23
23
24
24
$ router ->get ('bye ' , function () {
You can’t perform that action at this time.
0 commit comments