note 9380 added to session_get_cookie_params
| From: | evilghost at stickit dot nu | Date: | Mon, 30 Oct 2000 19:19:56 +0000 |
| Subject: | note 9380 added to session_get_cookie_params | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-7188@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.
<?
/* 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 . " " . $ip . " proxied " .
$redir . " using " . $agent . "<br>";
}
else{
$log =$datestamp . " " . $ip . " using " . $agent .
"<br>";
}
fputs($fp, $log);
fclose($fp);
}
?>
http://www.php.net/manual/function.session-get-cookie-params.php