PHP locked ip address
php
Solution
This code will delete the session (logout) if the user's IP address changes.
So the user can log in from any IP address, but will be logged out if it changes.
This could work to prevent session hijacking, but it wont work very well if you're on a dynamic IP because your IP will keep changing.
Problem
I lock the ip address. Does this mean than user can only login in with the same ip address? Or will the user logout and have to re-login to get a new session? ``` if (isset($_SESSION['last_ip']) === false) { $_SESSION['last_ip'] = $_SERVER['REMOTE_ADDR']; } if ($_SESSION['last_ip'] != $_SERVER['REMOTE_ADDR']){ session_unset(); session_destroy(); } ```