neversaint has asked for the wisdom of the Perl Monks concerning the following question:

Dear Masters,

I have a web app in created with CGI.pm, let's call it myapp.cgi (embedded within a normal html frame).
Is there a way to capture/record the IP addresses of users who submit job from myapp.cgi? I am thinking to capture it within myapp.cgi itself, not from the html file from where it is embedded.

---
neversaint and everlastingly indebted.......

Replies are listed 'Best First'.
Re: Capturing IP Address from a CGI script
by ides (Deacon) on Oct 27, 2007 at 15:41 UTC

    You can get the sending hostname ( or IP if the hostname is unavailable ) via $cgi->remote_host() and then log it to a file or store it however you want.

    Frank Wiles <frank@revsys.com>
    www.revsys.com

Re: Capturing IP Address from a CGI script
by andyford (Curate) on Oct 27, 2007 at 14:51 UTC

    What exactly do you want to do? There are probably many answers to your question depending on your end goal.

    If you just want a simple list of IPs and how they submitted myapp.cgi, then that job is usually done by the webserver. Check your logs. If the information is not in there, you can probably change your webserver's configuration to enable it.

    If, on the other hand, you want to set up some kind of session, you probably want to use cookies and some kind of Perl module that handles the whole session thing for you like, oh, say, CGI::Session :)

    non-Perl: Andy Ford