HOW TO redirect user to last visited page?

Discuss everything related to ApPHP Durecty CMF. All versions. Any questions related to the Directy CMF developing or using should be posted to this forum.

Moderators: alexandrleonenko, alexmst

administrator
Site Admin
Site Admin
Posts: 6169
Joined: Jan 7th, '09, 23:18
Contact:

HOW TO redirect user to last visited page?

Postby administrator » Aug 13th, '16, 09:13

From version 2.7 there is a new feature: "last visited page".
The syntax is following:

Code: Select all

Website::getLastVisitedPage()


Example of usage:

Code: Select all

$lastVisitedPage = Website::getLastVisitedPage();
if(!empty($lastVisitedPage) && !preg_match('/(login|loggedOut|registration|Home\/index|index\/index)/i', $lastVisitedPage)){
   $this->redirect($lastVisitedPage, true);
}
$this->redirect('users/dashboard');

Return to “ApPHP Directy CMF {developers/users}”