Re: Using sessions to gather visitor information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



the time difference is most likely becuase your server is in a different
time zone, or is at least set to a different time zone. When you run your
time calculations, you can add something like this:

$now = (time() - 18000);

that would give you the time on the server minus 5 hours. Now I don't know
the difference between time() and localtime() so I don't know how that will
affect the output.

-- 


-------------------------------------------------------------->>
Jasper Howard :: Database Administration
ApexEleven Web Design
1.530.559.0107
http://www.ApexEleven.com/
<<--------------------------------------------------------------
"Vincent Jordan" <vjordan@xxxxxxxxxxxxxxx> wrote in message
news:php.db-36196@xxxxxxxxxxxxxxx
> I am trying to track the users that visit one page on a site. I am having
a
> couple of problems. The time seems to be 5 hours off. I do not have any
> tables as of yet what I would like to do is only count an ip address as
one
> in a 24 hour period, if more than one visit then update visit count.I have
> played around with the time using date() and localtime().  Here is what I
> have sofar.
>
>
>
> ini_set('display_errors',1);
>
> error_reporting(E_ALL & ~E_NOTICE);
>
> session_start();
>
> $_SESSION['ip_address'] = $IP;
>
> $_SESSION['user_agent'] = $Browser;
>
> $_SESSION['host_name'] = $Host;
>
> $_SESSION['visit_time'] = $now;
>
>
>
> $now = localtime();
>
> $now = $now[2] . ":" . $now[1] . ":" . $now[0];
>
> $IP = getenv(REMOTE_ADDR);
>
> $Browser = $_SERVER['HTTP_USER_AGENT'];
>
> $Host = getHostByName($IP);
>
>
>
> I have not setup tables yet but I think I will use this:
>
> vid init(5) not null auto_incriment
>
> ip varchar(25) null
>
> agent varchar(100) null
>
> host varchar(100) null
>
> time varchar(10) nul
>
> visitcount int(100) null
>
>
>
> when a visitor loads the page I can run this
>
>
>
> mysql_query(SELECT ip, time FROM tablename where
ip=$_SESSION['ip_address']
> and time=$_SESSION['visit_time'])
>
>
>
> I would like to query if $_SESSION['ip_address'] has visited in less then
24
> hours then kill session and close mysql connection. If last visit was more
> than 24 hours update time and add +1 to visitcount. If new visit add to
> table.
>
>
>
> Once all done how can I properly clean up the session. I have tried the
> following bur get an error
>
> unset($_SESSION);
>
> session_destroy();
>
> I tried this with a link to another page and got this error:
>
> Warning: session_destroy(): Trying to destroy uninitialized session in
> /home/content/html/killtest.php on line 5
>
> I assume I forgot something.
>
>
>
> Any help would be appreciated.
>
>
>
>
>
>
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux