Hi!
I have this notice while anonymous user comes to my site first time

Notice: Undefined variable: _SESSION in smart_ip_set_session_data() (line 336 of /home/content/06/7198206/html/sites/all/modules/smart_ip/smart_ip.module).

"Anonymous user" in "Roles To Geolocate" is selected.

I'm new to PHP, so how can I fix this? Should I just add new line before 336?
$_SESSION['smart_ip']['location'] = array()
Thank you!

Comments

arpeggio’s picture

Status: Active » Fixed

Hello,

Tried to replicate your issue, using the following setup:
- Installed fresh Drupal 7.0
- Enabled Smart IP 7.x-1.4-alpha1 (Device Geolocation not enabled)
- Enabled "Anonymous user" in "Roles To Geolocate"

Then I tried to open different browser to simulate first time anonymous user comes to my site and I got:

Notice: Undefined variable: _SESSION in smart_ip_set_session_data() (line 334 of C:\xampp\htdocs\sites\all\modules\smart_ip\smart_ip.module).

The fix is:

  if (isset($_SESSION['smart_ip']['location'])) {
    $_SESSION['smart_ip']['location'] = array_merge($location, (array)$_SESSION['smart_ip']['location']);
  }
  else {
    $_SESSION['smart_ip']['location'] = $location;
  }

Already committed to CVS (Please use the development version). Thank you for reporting this bug.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.