Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Capturing IP Address from a CGI script

by neversaint (Deacon)
on Oct 27, 2007 at 14:33 UTC ( #647578=perlquestion: print w/replies, xml ) Need Help??
neversaint has asked for the wisdom of the Perl Monks concerning the following question:

Dear Masters,

I have a web app in created with, 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 <>

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://647578]
Approved by Arunbear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2018-05-28 05:13 GMT
Find Nodes?
    Voting Booth?