Page 1 of 2

get visitor IP address or mac address

Posted: Mon Aug 17, 2009 9:20 am
by nga
I dont know if this is the right section? Anyway, i've seen websites where users are automatically logout on one computer when they login to the site from another computer.That's pretty handy for website which offers remember me option and still want to secure their users. I know a bit about getting IP address of visitor by using asp .net but with php, i dont know if it possible?

Re: get visitor IP address or mac address

Posted: Mon Aug 17, 2009 9:27 am
by susrisha
yes .. its possible.

Code: Select all

 
$_SERVER[REMOTE_ADDR];//look for the documentation in PHP manual
 
@moderator:
I beleive this post should go to PHP Code forum.

Re: get visitor IP address or mac address

Posted: Mon Aug 17, 2009 1:38 pm
by VladSun
get visitor IP address or mac address
About getting the user's MAC address - take a look at this:
viewtopic.php?f=6&t=89514

Re: get visitor IP address or mac address

Posted: Mon Aug 17, 2009 11:09 pm
by nga
i appreciate it alot you guys :D

Re: get visitor IP address or mac address

Posted: Mon Aug 17, 2009 11:14 pm
by nga
this link viewtopic.php?f=6&t=89514 explain how to get mac address in a LAN or wireless network. i want to get visitor(of my website)'s MAC address. Is is possible by php or something else?

Re: get visitor IP address or mac address

Posted: Tue Aug 18, 2009 12:12 am
by nga
oh i get it, do you mean we cant get MAC address?

Re: get visitor IP address or mac address

Posted: Tue Aug 18, 2009 1:10 am
by VladSun
Simply, you can get the user's MAC address in a single network segment (like "Intranet" sites) but you can't get it in the Internet network.

Re: get visitor IP address or mac address

Posted: Tue Aug 18, 2009 4:35 am
by nga
For example, if you login to a website(donot logout) and then using another computer(same LAN and same public IP address) login to that website then the website cannot identify that you have log in from abother computer?

Re: get visitor IP address or mac address

Posted: Tue Aug 18, 2009 6:22 am
by VladSun
(same LAN and same public IP address)
I supose you mean that the LAN IPs are routed to Internet by using SNAT (PAT) - i.e. single public IP.

In this case you can distinguish them by using the session ID or some cookie information.

Re: get visitor IP address or mac address

Posted: Tue Aug 18, 2009 9:03 am
by nga
do session IDs not disappear when you close the browser? Well, i gues what i want to ask is to mimic this website neopets.com (when you login to the site from a different computer, the next time you/someone else visit the website on the old computer, your account are logged out even though the computer you used is still in the same LAN). I figured that they use MAC address or something? or they use a combination of cookies and IP address?

Re: get visitor IP address or mac address

Posted: Tue Aug 18, 2009 10:15 am
by pickle
I don't think IP addresses need to be stored at all.

When a user logs in on computer A, that computer gets a cookie with a session ID. That same session ID is stored server-side and is associated with that particular user.

When that same user accesses the site via computer B, computer B doesn't have a cookie with the proper session ID, so the user isn't logged in. If the user logs in on computer B, computer B gets a session ID, and the server is updated with the session ID as stored on computer B.

At this point, computer A no longer has the proper session ID for the user, so it is treated as a non-logged in user.

Re: get visitor IP address or mac address

Posted: Tue Aug 18, 2009 10:52 am
by nga
then the user account is still vulnerable if the cookie is captured? So in order to be really really secure, sessionID, IPaddress should be used together? if session ID the same and IP address is different +> cookie might be capture => logout. Seem like a great idea

Re: get visitor IP address or mac address

Posted: Tue Aug 18, 2009 11:04 am
by jackpf
That's how most people do it I believe. Some people also check user agents to make sure the browser is the same.

Re: get visitor IP address or mac address

Posted: Tue Aug 18, 2009 12:21 pm
by VladSun
Another related thread to point to:
viewtopic.php?f=19&t=96910
:)

Re: get visitor IP address or mac address

Posted: Tue Aug 18, 2009 1:02 pm
by nga
about IP spoofing, I'm curious on how this could be done and how to prevent it?