I do have a landing page in my website, in each page i have a PHP code which will be check the cookies and if user has the specific cookie it will stay at that page and if doesn't it will redirect to the landing page. On the landing page i do have a button which when users click on it, the cookie will be created.
When user clicks on the button the pages should goes back to the previous page which was before. My code is
if(isset($_COOKIE['username'])){
$_COOKIE['username'];
header('location: http://example.com/main');
}
else{
//
}
Is there anyway to find the previous page link or original requested URL?