Skip to content

Commit bbf7207

Browse files
authored
Update DatabaseSessionHandler.php
tlaverdure/laravel-echo-server#546 When request doesn't has `ipAddress` or 'User-Agent' don't overwrite the last one
1 parent dcda06f commit bbf7207

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Illuminate/Session/DatabaseSessionHandler.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,13 @@ protected function userId()
233233
*/
234234
protected function addRequestInformation(&$payload)
235235
{
236-
if ($this->container->bound('request')) {
237-
$payload = array_merge($payload, [
238-
'ip_address' => $this->ipAddress(),
239-
'user_agent' => $this->userAgent(),
240-
]);
236+
if (! $this->container->bound('request')) {
237+
if ($this->ipAddress()) {
238+
$payload['ip_address'] = $this->ipAddress();
239+
}
240+
if ($this->userAgent()) {
241+
$payload['user_agent'] = $this->userAgent();
242+
}
241243
}
242244

243245
return $this;

0 commit comments

Comments
 (0)