Please avoid or flag spams/hateful comments. And do not spam. Enjoy 🙂
Subscribe my Channel:-
Tweets by UnpossiblePOG
Hey guys, this is UNPOSSIBLE POG.
In this video, I shall explain the easiest way redirect to the last visited page after login using core PHP, without session or database.
This will help website visitors to navigate where he or she left of. For example if that person is watching products and if he logs in, he doesn’t have to do same procedure to go to that product or page.
You can use same logic for logout if you have a PHP knowledge.
As you can see, I created a pages with links.
And there is a common file called “header.php” which is included in each file.
Lets start with coding in header.
Create php tag and first we shall find protocol.
In localhost, there is always http, but we are also creating a code for https.
Once protocol is found, we overwrite the variable and find the whole URL by using this code.
I made a mistake, there should be “HOST” instead of “POST”.
After that, we are creating a request variable called page_url, and echo that variable.
As you can see, if I click on page1, then click on “LOGIN”, it shows the previously visited page in browser’s URL.
Lets try it once again.
Lets move ahead. in login page, we make a business logic for login, if username and password is 123, then we shall redirect to website to previously visited page.
If i click on page 2, then login, it will redirect me to page2.
Lets try that again but by clicking page3 first.
As you can see, the code is successful, the code link is in the description.
Thanks for watching.