can any one tell how to implement this in php and mysql

5 replies
In php i'm setting the flag for visitor visiting my website in database(it is '1' when they are visiting),
if the user closes the page, it will end the session and update their flag in database as '0'

Thanks & Regards

Katy Peterson
#implement #mysql #php
  • Profile picture of the author HJdev
    In stead of setting a flag, set a timestamp every time the visitor views a page.

    Code:
    seconds = currentTimestamp - visitorTimestamp;
    
    if (seconds < 60) {
      visitor = "Online";
    } else {
      visitor = "Offline";
    }
    Signature
    Discover how my Internet Marketing Tools increase your business efficiency...
    HJToolBox.com
    {{ DiscussionBoard.errors[8890571].message }}
  • Profile picture of the author thatthep
    or use java script event for detect when user leave the page then send data back to server.
    {{ DiscussionBoard.errors[8891021].message }}
  • Profile picture of the author vaghela dev
    Hello sir,

    Please use this code.

    if(second < 60):
    visitoer = ""Online";
    elseif:
    visitor = "Offline';
    endif;
    {{ DiscussionBoard.errors[8892162].message }}
    • on point yep this is absolutely the rite way to get it done.

      Originally Posted by vaghela dev View Post

      Hello sir,

      Please use this code.

      if(second < 60):
      visitoer = ""Online";
      elseif:
      visitor = "Offline';
      endif;
      Signature
      WebDevelopmentGroup NYC & CA- Small Business Web Development, App Development, WordPress Development, Graphic Designs, Online Marketing, Local Marketing & more!. "Call us 1.800.219.1314 or message us!". Visit us today! "Now On Live Chat Mon-Fri.". www.WebDevelopmentGroup.org
      (Whitelable our Services)
      ===================================
      ==> #1 OFFLINE MARKETING FORUM ON THE WEB! <==
      www.OFFLINEMARKETINGFORUM.com
      (Register Now)
      {{ DiscussionBoard.errors[8896173].message }}
  • Profile picture of the author Zdenek Koukol
    Depending what you would like to do with this information. If you are counting number of users available on the site, then you should use something else. No always will be execute javascript, when somebody close window of the browser. What you can do is create small callback in javascript (ajax), which is sending request to the server which will update variables in the session - logic here is not checking if user is away, but checking if user is still LIVE (connected). Of course here depending what is configured timeout for sessions, but if you need faster recognition, then you can store in session value with timestamp. And if this will pass, then you know that user is away. Script which is handling this sessions staff can update your statuses in DB. Here I have small question. How do you store user? Is this user logged in your system or is just some visitor and your are storing his session ID?
    Signature

    Check my website ... http://www.becomerichforever.com

    {{ DiscussionBoard.errors[8897652].message }}

Trending Topics