My client needs to show (anonymous) foreigners a message when they arrive at the site... no matter which page they're visiting.
I'm going to show the message via jQuery 'Meerkat' plugin, but that's not the challenge.
Seems like I need to write a module (or a block?) that essentially does this:
1) is this a new session for anonymous visitor? (is this the first pageview of this session?)
2) if yes to (1), is the visitor IP from another country
3) if yes to (1) & (2), then add javascript...

I can't seem to find any documentation on (1): how do I determine if this is a visitor's first page-view (for this session)?

Comments

jaypan’s picture

Here is a rough idea of how you can do it

function my_module_init()
{
  if(user_is_anonymous())
  {
    if(!sess_read('splash_page_seen'))
    {
      $ip = get_users_ip(); // you will have to write this function
      if(user_is_foreign($ip)) // you will have to write this function. It should return true or false
      {
        // add javascript here
        sess_write('splash_page_seen', TRUE);
      }
    }
  }
}

Contact me to contract me for D7 -> D10/11 migrations.

andjules’s picture

thanks, that's a great start