That depends on your system. I use a variable
$page in all my pages(obtained from parsing
$_SERVER['REQUEST_URI']) and my login link would look like
PHP Code:
<a href="login.php?page=<?php echo $page;?>">Login</a>
or
PHP Code:
<a href="/login/<?php echo $page;?>/">Login</a>
(in case of a friendly url setup

)
My login.php page reads the request from $_GET['page'], and stores this value in session or a hidden variable.
On a successful login, a switch block like
PHP Code:
if(!empty($_SESSION['page'])){
switch($_SESSION['page'])
case 'home': $target='index.php?page=home';
#or home.php or whatever
break;
case 'about': $target='index.php?page=about';
#or about.php or whatever
break;
...
}
unset($_SESSION['page']);
}
if(!isset($target))
$target='profile.php';
header("Location:". $target); #you may need to add the complete path here
Hope this helps.