2

I'd like to know if is there any way to know if it is the first visit of a Anonymous User?

If so, can I fire up a rule to redirect the visitor to other page.

  • @NikhilM That is for authenticated user, this question as it is, includes anonymous as well. – GoodSp33d Mar 27 '13 at 13:15
  • 1
    @chefnelone Its really hard to track anonymous users first visit, simplest way is to test for a cookie, if its not there its his first visit and then you drop a cookie. But this logic will fail if user cleared cookies. – GoodSp33d Mar 27 '13 at 13:17
  • @2-Stroker: I think you are right, a cookie would be the only way to do this. Any module to create cookie? Do I need to create the cookie programmatically? – chefnelone Mar 27 '13 at 13:19
  • 1
    @2-Stroker why would you do this at the theme layer? What happens when they switch themes? This definitely belongs in a module. – Adam Balsam Mar 27 '13 at 14:13
1

Why not set a cookie when folks visit, then you can check for whether they have the cookie. No cookie = first time visitor.

| improve this answer | |
0

Yes there is a way;

In the Global $user check for access if its set to 0, the user is never logged in to the site.

function mymodule_user_login(&$edit, $account) {
  if ($account->access == 0) {
    // The user has never logged in before.
  }
}

When i posted the answer the question was like this https://drupal.stackexchange.com/revisions/66946/1

| improve this answer | |
  • 1
    but this is for authenticated user. I need it for anonymous users. I think that the only way way is a cookie. – chefnelone Mar 27 '13 at 13:17
  • This wont work for anonymous users – GoodSp33d Mar 27 '13 at 13:18
  • @2-Stroker when i posted the answer the question was like this drupal.stackexchange.com/revisions/66946/1 – niksmac Mar 27 '13 at 14:59
0

You can manage it by inserting cookies in the user's browser. After that check, it has cookies or not and do your further things. :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.