note 9380 deleted from function.session-get-cookie-params by jimw

From: Date: Mon, 17 Dec 2001 23:32:13 +0000
Subject: note 9380 deleted from function.session-get-cookie-params by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23091@lists.php.net to get a copy of this message
Here is some basic code that will do connection logging via sessions. Feel free to modify, I know a few people looking to do something similar. &lt;? /* Session Logging code, basic but it works well. * * October 25th, 2000 Created by evilgh0st, http://www.stickit.nu * * This must be placed before the <head> statement in your HTML */ /* Get global vars we need */ $ip = getenv("REMOTE_ADDR"); $redir = getenv("HTTP_FORWARDED"); $agent = getenv("HTTP_USER_AGENT"); $datestamp = date("D F d @ G:i T"); /* Start session */ session_start(); /* If the $newuserid is set to a value then this user has been here before, dont log */ if (isset($newuserid)){ /* Do nothing, we dont want anything different going on for normal users who are already logged */ /* So we won't put anything here, if you wanted to do something special for logged users put it here */ } else{ session_register("newuserid"); /* Set the 'cookie' to the visiting users IP */ $newuserid = $ip; /* Open our logging file */ $fp = fopen ("visitors.html", "a"); if ($redir != ""){ $log = $datestamp . "&nbsp;" . $ip . "&nbsp;proxied&nbsp;" . $redir . "&nbsp;using&nbsp;" . $agent . "<br>"; } else{ $log =$datestamp . "&nbsp;" . $ip . "&nbsp;using&nbsp;" . $agent . "<br>"; } fputs($fp, $log); fclose($fp); } ?>

« previous php.notes (#23091) next »