I want to know how to redirect user to particular link after login in php
for example in e-commerce website if user click on add to cart button and if that user is not logged in then user will be redirected to login page and after login user will be redirected to cart page which is requested page
so,i want to know how to code for this.
if(!empty($_SESSION['username']))
{
$url=' .php';//here i want dynamic link which is requested page link when user tries to access
}
else
{
$url='login.php';
}