Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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 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.......

Comment on Capturing IP Address from a CGI script
Select or Download Code
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

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://647578]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2014-07-29 07:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls