Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Capturing IP Address from a CGI script

by neversaint (Deacon)
on Oct 27, 2007 at 14:33 UTC ( [id://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.......

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-24 08:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found