Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Capturing a visitors IP address


Go to End


3 Posts   3575 Views

Avatar
TerryMiddleton

Community Member, 108 Posts

4 May 2009 at 12:15pm

Couple of questions.

1.) Is there a way to capture a visitors IPAddress ?

2.) Can I store the address in a log file?

3.) Is there a way to create a unique table in the database that stores more information that the user's login information. Such as name, address, email, etc.?

Thanks,

Terry

Avatar
Kalileo

Community Member, 127 Posts

4 May 2009 at 6:09pm

About the visitors IPAddress, dunno if SS has a special function, but look at the content of $_SERVER, such as

$ip = $_SERVER['REMOTE_ADDR'];

this can be manipulated though, have a look also at 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'HTTP_VIA', 'HTTP_X_COMING_FROM', 'HTTP_COMING_FROM', always as fields of $_SERVER.

Avatar
TerryMiddleton

Community Member, 108 Posts

4 May 2009 at 10:19pm

Yeah, I'll give that a whirl.

I'll create a field in the form and pass it the value of $_SERVER['REMOTE_ADDR']

Let's see how that works.

Thanks for the hint. Wasn't thinking clearly and thinking that everything had to be SS specific.

Terry