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

Logging Logged in User's IP Addresses


Go to End


3 Posts   1510 Views

Avatar
purplespider

Community Member, 89 Posts

6 August 2010 at 8:49pm

I have a SilverStripe site where users have to pay a subscription fee in order to be able to view the site content.

I would like to log user's IP addresses when they access the site, so that in future I can detect if a user is logging in for different IP addresses at the same time, which would be an indication this user has given their login details to another party.

What is the best way to go about doing this? I presume I have 2 choices, log IP upon login or upon visiting, I believe "LastVisited" updates every time a user changes pages, so would that add too much overhead if I was logging their IP each time too?

Either way, how can I perform an action upon "login" and upon "visited"?

Thanks
James

Avatar
swaiba

Forum Moderator, 1899 Posts

8 August 2010 at 6:32am

hmmm I'd be very interested what you end up with... my suggestions would be....

1) to decorate/use custom class the Member (I can't remember which I've used at the moment) then use an onAfterWrite and note when 'LastVisited' changed (http://api.silverstripe.org/2.4/sapphire/model/DataObject.html#methodgetChangedFields).

2) to add something like this to Page.ss
<% if CurrentMember %>$MyMemberIPLoggerFunction<% end_if %>

Hope this helps,

Barry

Avatar
purplespider

Community Member, 89 Posts

9 August 2010 at 9:42pm

Thanks swaiba. That sounds I good place to start. I'll let you know how I get on.

James