tracking user logins per day
<p>hey guys i'm running a script on my site:
as a user logs into my website i write this days date into a text file so i can know at witch days the user was active on my website.
the thing is, if a user lets say didn't log out from the site for 2 days or more how can i check if he was on the site on those days? can some one give me a good suggestion?</p>

<p>here is the code i'm running as part of my login, just before i register the session: (by the way ill be glad to hear if there's a better way to do it?) </p>

<pre><code>      $log_file_name = "logfile.txt";
      $log_file_path = "log_files/$id/$log_file_name";

      if(file_exists($log_file_path)){
      $not = "";
      $todaydate = date('d,m,Y');
      $today = "$todaydate;";
      $strlength = strlen($today);
      $file_contents = file_get_contents($log_file_path);
      $file_contents_arry = explode(";",$file_contents);
      if(!in_array($todaydate,$file_contents_arry)){
      $append = fopen($log_file_path, 'a');
      $write = fwrite($append,$today); //writes our string to our file.
      $close = fclose($append); //closes our file    
      }
      else if(in_array($todaytodaydate,$file_contents_arry)){}



      }
      else{
      mkdir("log_files/$id", 0700);
      $todaydate = date('d,m,Y');
      $today = "$todaydate;";
      $strlength = strlen($today);
      $create = fopen($log_file_path, "w");
      $write = fwrite($create, $today, $strlength); //writes our string to our file.
      $close = fclose($create); //closes our file
      }
</code></pre>
