Community Add-Ons

Add file to this package
Top » Features

Login and Return to same page
for osCommerce Online Merchant v2.2

This allows User's to log in and return to the page they were asked to login for, not being sent back to index.php

Open application top paste at bottom before ?>



// if the customer is not logged on, set the page to return to upon login

if ( (basename($PHP_SELF) != FILENAME_LOGIN) && (basename($PHP_SELF) != FILENAME_LOGOFF) && (!strstr($PHP_SELF,'create')) && (!strstr($PHP_SELF,'popup')) {

$navigation->set_snapshot();

}


**************************************

Open Logout.php
Place anywhere

if (sizeof($navigation->snapshot) > 0) {

$origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);

$navigation->clear_snapshot();

$link = $origin_href;

} else {

$link = tep_href_link(FILENAME_DEFAULT);

}


******************
Thats all

Legend:  Download   Report

Expand All / Collapse All

Login and Return to Previous Page (but not the un-intended page)s kgtee 6 Nov 2016  

My site login is via the "My Account" button on the header, which redirects to account.php. This login always return the user to the account.php page instead of the page where the user has just left. So, I started to look for a mod to change this behaviour and am glad to found this add-on. Thanks to the original author.

My mod below seems to work for me.

The way to prevent login page to return to itself (or other pages, like logoff, create_account, password_forgotten etc) but to the page where the user previously left, is to clear the snapshot on these pages. Without a snapshot, user is redirected to FILENAME_DEFAULT automatically upon login.

The following mod should work.


1) In includes/header.php:

Add on top of file,

<?php
// -- first any page other than login.php, set snapshot --
if (basename($PHP_SELF) != FILENAME_LOGIN) {
$navigation->set_snapshot();
}
$origin_page = $navigation->snapshot['page'];
// -- clear the snapshot for the following pages --
if (($origin_page = FILENAME_LOGOFF) or ($origin_page = FILENAME_CREATE_ACCOUNT) or ($origin_page = FILENAME_CREATE_ACCOUNT_SUCCESS) or ($origin_page = FILENAME_PASSWORD_FORGOTTEN)) {
$navigation->clear_snapshot();
}
?>


2) If you activate the login.php through account.php, then it is necessary to remove the snapshot setting in account,php to prevent returning to itself again:

On line 16, change the line to or delete the line,

/* $navigation->set_snapshot(); */


-------------------------------------
Note: No file is uploaded for this mod.

Final Solution reflex-ocasion 30 Apr 2011  
Use this method by demoalt xp02ed 29 Jul 2010  
Use this contrib on your own risk! RusNN 4 May 2010  
Login and Return to same page AndreN 3 May 2010  
Updated full pack luckyno 12 Dec 2009  
Small Fix: faaliyet 9 Dec 2009  
Fix Error trikinuke 9 Dec 2009  
Login and Return to same page Van Loco Gunther 19 Apr 2005  
Login and Return to same page Joma Webdesign 18 Apr 2005