aj123cd Posted April 2, 2012 Share Posted April 2, 2012 Can I Lock the session to a specific IP address? If(isset($_SESSION[‘last_ip’] )) == false) { $_SESSION[‘last_ip’] =$_SESSION[‘REMOT_ADDR’]; } if($_SESSION[‘last_ip’] != =$_SESSION[‘REMOT_ADDR’]){ session_unset(); session_destroy(); } thank you in advance Quote Link to comment https://forums.phpfreaks.com/topic/260203-lock-the-session-to-a-specific-ip-address/ Share on other sites More sharing options...
batwimp Posted April 2, 2012 Share Posted April 2, 2012 Your question is fairly vague. What exactly are you trying to use this for? Quote Link to comment https://forums.phpfreaks.com/topic/260203-lock-the-session-to-a-specific-ip-address/#findComment-1333656 Share on other sites More sharing options...
aj123cd Posted April 2, 2012 Author Share Posted April 2, 2012 store user information on the server for later use Quote Link to comment https://forums.phpfreaks.com/topic/260203-lock-the-session-to-a-specific-ip-address/#findComment-1333682 Share on other sites More sharing options...
max_w1 Posted April 2, 2012 Share Posted April 2, 2012 You can store the info in database with the user's IP, or just place a cookie in users computer with the information. as far as i know, sessions get destroyed when the browser is closed. Quote Link to comment https://forums.phpfreaks.com/topic/260203-lock-the-session-to-a-specific-ip-address/#findComment-1333692 Share on other sites More sharing options...
aj123cd Posted April 2, 2012 Author Share Posted April 2, 2012 what about proxy server IP address? Quote Link to comment https://forums.phpfreaks.com/topic/260203-lock-the-session-to-a-specific-ip-address/#findComment-1333693 Share on other sites More sharing options...
batwimp Posted April 2, 2012 Share Posted April 2, 2012 That's the problem with using IP addresses to keep track of user information. IP addresses can change for a number of reasons. Using IP addresses to store unique user information isn't reliable. The best way to keep track of individual user stuff is to have login functionality. Quote Link to comment https://forums.phpfreaks.com/topic/260203-lock-the-session-to-a-specific-ip-address/#findComment-1333695 Share on other sites More sharing options...
freeloader Posted April 3, 2012 Share Posted April 3, 2012 You could use IP information as an added layer of security. First you need to find the IP address. $_SERVER["REMOTE_ADDR"] isn't always the most reliable. There are some great functions out there, just google for 'php find ip address' or something like that. Best way to store that info is on a database on your server in a field like 'LastIP' and then compare current with last IP and else: send them back to login page. Quote Link to comment https://forums.phpfreaks.com/topic/260203-lock-the-session-to-a-specific-ip-address/#findComment-1333883 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.