Link to home
Start Free TrialLog in
Avatar of carrot
carrot

asked on

Detect RELOAD in cgi and how to figure out the date?

I want to know if someone is reloading my page(ie, click the
RELOAD button), can I  use some variables in cgi to do this?

How to get the date since there is no such environment variable available? please tell me in details. (say currentTime = date(...) or something like that)

And finally, I want to figure out who are currently on
my page, that is, to find out all the users who are currently on my page.(use REMOTE_ADDR can get only one
of them)

Thanks.
Avatar of Wayne Leister
Wayne Leister
Flag of United States of America image

I have an answer for the second question(date).  You need to use the time function(gives you seconds since 1970) then feed that into the localtime function.  It returns a list with the date:
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)= localtime(time);
$mday is the day of the month
$mon is the month
$year is the year
$wday is the day of the week

Avatar of jpk041897
jpk041897

Regarding the first question:

You could set up an invisible applet on your page. Whenever a page is loaded (or reloaded) Java's Applet.start() method is called. You could set up a counter that determines how many times the page has been loade. If > 1, and the time frame is less than say 5 or 10 seconds, the user is refreshing the page.

Re.: question 2, an applet can detect the IP of the user that loaded it, it could transmit this info, via a socket, to a remote server.

Re.: question 3, an applet can also obtain time information and save it on a file on the host.

Of course, you posted this question on the CGI topic section so I don't know if an applet solution is acceptable to you, thus I post as a comment and don't give additional details.

Your CGI code could read a file generated by an applet though, to obtain the info you require so, if no one can produce a better answer and/or a combination applet/CGI solution is acceptable I'd be glad to post an answer with additional details.
ASKER CERTIFIED SOLUTION
Avatar of julio011597
julio011597

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of carrot

ASKER

This answer helps a lot, thanks.
but I can't give more points since I have nearly none
left. Think I may want to ask one or more questions. ^.^

Thanks again.