You can take the url and explode "/" like this:
$url = explode("/",$_SERVER['REQUEST_URI']);
Then configure the session to save the username that he has accessed as follows:
$_SESSION['used_name'] = $url[0];
And you can configure the page to which it is redirected after a successful login, for example:
$success_page = "yourpage/".$_SESSION['used_name'];
Hope this is what you were looking for.
source
share