Skip to content

Commit

Permalink
Avoid overwrite last ip or user_agent with empty ones
Browse files Browse the repository at this point in the history
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
  • Loading branch information
PaolaRuby committed Nov 23, 2021
1 parent dcda06f commit 417d098
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Illuminate/Session/DatabaseSessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,12 @@ protected function userId()
protected function addRequestInformation(&$payload)
{
if ($this->container->bound('request')) {
$payload = array_merge($payload, [
'ip_address' => $this->ipAddress(),
'user_agent' => $this->userAgent(),
]);
if ($this->ipAddress()) {
$payload['ip_address'] = $this->ipAddress();
}
if ($this->userAgent()) {
$payload['user_agent'] = $this->userAgent();
}
}

return $this;
Expand Down

0 comments on commit 417d098

Please sign in to comment.