Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use session to store the last visited page #565

Merged
merged 4 commits into from Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 14 additions & 5 deletions core-bundle/src/Resources/contao/modules/ModuleLogin.php
Expand Up @@ -35,6 +35,11 @@ class ModuleLogin extends Module
*/
protected $strFlashType = 'contao.FE.error';

/**
* @var string
*/
private $targetPath = '';

/**
* Display a login form
*
Expand All @@ -56,7 +61,11 @@ public function generate()

if (!$_POST && $this->redirectBack && ($strReferer = $this->getReferer()) != Environment::get('request'))
{
$_SESSION['LAST_PAGE_VISITED'] = $strReferer;
$this->targetPath = Environment::get('base') . $strReferer;
}
else
{
$this->targetPath = (string) Input::post('_target_path');
}

return parent::generate();
Expand All @@ -82,9 +91,9 @@ protected function compile()
$strRedirect = Environment::get('base').Environment::get('request');

// Redirect to last page visited
if ($this->redirectBack && $_SESSION['LAST_PAGE_VISITED'] != '')
if ($this->redirectBack && $this->targetPath)
{
$strRedirect = Environment::get('base').$_SESSION['LAST_PAGE_VISITED'];
$strRedirect = $this->targetPath;
}

// Redirect home if the page is protected
Expand Down Expand Up @@ -125,10 +134,10 @@ protected function compile()
$strRedirect = Environment::get('base').Environment::get('request');

// Redirect to the last page visited
if ($this->redirectBack && $_SESSION['LAST_PAGE_VISITED'] != '')
if ($this->redirectBack && $this->targetPath)
{
$blnRedirectBack = true;
$strRedirect = $_SESSION['LAST_PAGE_VISITED'];
$strRedirect = $this->targetPath;
}

// Redirect to the jumpTo page
Expand Down
10 changes: 2 additions & 8 deletions core-bundle/src/Resources/contao/modules/ModuleLogout.php
Expand Up @@ -52,19 +52,13 @@ public function generate()
return $objTemplate->parse();
}

// Set last page visited
if ($this->redirectBack)
{
$_SESSION['LAST_PAGE_VISITED'] = $this->getReferer();
}

$strLogoutUrl = System::getContainer()->get('security.logout_url_generator')->getLogoutUrl();
$strRedirect = Environment::get('base');

// Redirect to last page visited
if ($this->redirectBack && !empty($_SESSION['LAST_PAGE_VISITED']))
if ($this->redirectBack && ($strReferer = $this->getReferer()))
{
$strRedirect = $_SESSION['LAST_PAGE_VISITED'];
$strRedirect = $strReferer;
}

// Redirect to jumpTo page
Expand Down
10 changes: 2 additions & 8 deletions core-bundle/src/Resources/contao/pages/PageLogout.php
Expand Up @@ -31,19 +31,13 @@ class PageLogout extends Frontend
*/
public function getResponse($objPage)
{
// Set last page visited
if ($objPage->redirectBack)
{
$_SESSION['LAST_PAGE_VISITED'] = $this->getReferer();
}

$strLogoutUrl = System::getContainer()->get('security.logout_url_generator')->getLogoutUrl();
$strRedirect = Environment::get('base');

// Redirect to last page visited
if ($objPage->redirectBack && !empty($_SESSION['LAST_PAGE_VISITED']))
if ($objPage->redirectBack && ($strReferer = $this->getReferer()))
{
$strRedirect = $_SESSION['LAST_PAGE_VISITED'];
$strRedirect = $strReferer;
}

// Redirect to jumpTo page
Expand Down