Jump to:

23355 Posts in 17873 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Logging Logged in User's IP Addresses

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

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

Page: 1
Go to End
Author Topic: 1056 Views
  • purplespider
    Avatar
    Community Member
    81 Posts

    Logging Logged in User's IP Addresses Link to this post

    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

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Logging Logged in User's IP Addresses Link to this post

    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

  • purplespider
    Avatar
    Community Member
    81 Posts

    Re: Logging Logged in User's IP Addresses Link to this post

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

    James

    1056 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.