seog Posted March 2, 2017 Share Posted March 2, 2017 (edited) Hello I am trying redirect to same page after login but it always redirect me to last visited page. I need to add the correct variable in value="{$smarty.server.HTTP_REFERER}" <input type="hidden" class="hidden" name="back" value="{$smarty.server.HTTP_REFERER}" /> <input type="submit" id="SubmitLogin" name="SubmitLogin" class="signin_submit" value="{l s='Login'}"></input> Example: When I am login in product page then the variable {$smarty.server.HTTP_REFERER} redirect me to previous visited page (category) instead to back to product page Do you think what it could work adding the next referer codes before input login buttons? {if $smarty.server.HTTP_REFERER == "http://www.mywebsite.com/index.php?controller=product"} {if $smarty.server.HTTP_REFERER == "http://www.mywebsite.com/index.php?controller=category"} {if $smarty.server.HTTP_REFERER == "http://www.mywebsite.com/index.php?controller=contact"} {if $smarty.server.HTTP_REFERER == "http://www.mywebsite.com/index.php?controller=cms"} Additional codes that maybe should be modified in controllers/front/AuthController.php Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account')); Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : $back)); Some suggestions? Thank you very much BR Edited March 2, 2017 by seog (see edit history) Link to comment Share on other sites More sharing options...
jetway Posted March 2, 2017 Share Posted March 2, 2017 Well the {$smarty.server.HTTP_REFERER} throws you to the referring page so this is the last visited one. You'll have to change that. I am not sure which php "variable" is available in Prestashop for this but I would assume something like PHP_SELF. Link to comment Share on other sites More sharing options...
seog Posted March 4, 2017 Author Share Posted March 4, 2017 Some suggestions please? Thank you very much Link to comment Share on other sites More sharing options...
seog Posted March 5, 2017 Author Share Posted March 5, 2017 Hello Does anyone really know the code to return to the same page after login? I read to threads but any works for PS 1.6, such as: https://www.prestashop.com/forums/topic/266211-solved-redirect-to-last-page-after-login-15/ https://www.prestashop.com/forums/topic/299268-solved-when-user-logins-redirect-to-same-page/ best regards Link to comment Share on other sites More sharing options...
sooroos Posted June 21, 2017 Share Posted June 21, 2017 (edited) Hi, i had the same situation, because i use the login form in a modal, so basically "HTTP_REFERER" wasnt the solution for me. i have used: <input type="hidden" class="hidden" name="back" value="{if isset($force_ssl) && $force_ssl}https://{else}http://{/if}{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}"/> Edited June 21, 2017 by sooroos (see edit history) Link to comment Share on other sites More sharing options...
Aumanz Posted April 27, 2018 Share Posted April 27, 2018 Reply from @shniurs on other post.. Quote Been looking for the solution whole day, after I posted this post it took me few minutes to figure this out. The solution: find this code in AuthController.php if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) Tools::redirect(html_entity_decode($back)); Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account')); Replace it with this code: if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) Tools::redirect(html_entity_decode($back)); Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL); It will redirect you to the same page where login form was submitted. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now