Skip to content

Commit 417d098

Browse files
authored
Avoid overwrite last ip or user_agent with empty ones
tlaverdure/laravel-echo-server#546 In some cases request doesn'nt has `ipAddress` or `userAgent`, with this change it avoid overwrite the last reported data
1 parent dcda06f commit 417d098

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Illuminate/Session/DatabaseSessionHandler.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,12 @@ protected function userId()
234234
protected function addRequestInformation(&$payload)
235235
{
236236
if ($this->container->bound('request')) {
237-
$payload = array_merge($payload, [
238-
'ip_address' => $this->ipAddress(),
239-
'user_agent' => $this->userAgent(),
240-
]);
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)