Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

User LogOut


s3rro

Recommended Posts

Posted

How does a user logout from the shopping cart system?

 

I dont see a log off,out button when i log in ass a user.

 

If theres a solution for that can someone share it.

 

Thanks

Posted

Here's some pretty generic osC code that will display a "Login" link if you're not logged in, and a "Logout" link if you are logged in.

 

<?php if (tep_session_is_registered('customer_id')) {
 echo '<a href="';
 echo tep_href_link(FILENAME_LOGOFF, '', 'SSL');
 echo '">Logout</a>';
} else {
 echo '<a href="';
 echo tep_href_link(FILENAME_LOGIN, '', 'SSL');
 echo '">Login</a>';
}?>

:)

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

Well... You can put it almost anywhere you want it.

 

It just depends on your installation I guess.

 

Most likely in your "/catalog/index.php", or "/index.php" file somewhere....

;)

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

One more thing...

 

This presumes you have an SSL certificate active.

 

If not, you may need to change "SSL" to "NONSSL" in two places...

:blush:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

thanks it works, but it pops up at the top of the page, how can put it beside the shopping cart at the top right . Thanks I dont have SSL

Posted
how can put it beside the shopping cart at the top right

I'd have to see your PHP source to help with that.

 

If you want, copy/paste it into your next post and I'll try to help.

:)

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

I got it , Thanks,

I put it under includes/header and now its beside the shopping cart.

 

Thanks

Posted

You're welcome...

;)

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

  • 4 months later...
Posted

HI!

 

i've put the same code in my header.php but when i click logout it gives me this error:

 

Not Found

The requested URL /shop/osc/<a was not found on this server.

 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

I'll paste my code from header.php and can u please tell me what i should change?

 

thank you very much!

 

<?php

/*

$Id: header.php,v 1.42 2003/06/10 18:20:38 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

// check if the 'install' directory exists, and warn of its existence

if (WARN_INSTALL_EXISTENCE == 'true') {

if (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/install')) {

$messageStack->add('header', WARNING_INSTALL_DIRECTORY_EXISTS, 'warning');

}

}

 

 

// check if the configure.php file is writeable

if (WARN_CONFIG_WRITEABLE == 'true') {

if ( (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) && (is_writeable(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) ) {

$messageStack->add('header', WARNING_CONFIG_FILE_WRITEABLE, 'warning');

}

}

 

// check if the session folder is writeable

if (WARN_SESSION_DIRECTORY_NOT_WRITEABLE == 'true') {

if (STORE_SESSIONS == '') {

if (!is_dir(tep_session_save_path())) {

$messageStack->add('header', WARNING_SESSION_DIRECTORY_NON_EXISTENT, 'warning');

} elseif (!is_writeable(tep_session_save_path())) {

$messageStack->add('header', WARNING_SESSION_DIRECTORY_NOT_WRITEABLE, 'warning');

}

}

}

 

// check session.auto_start is disabled

if ( (function_exists('ini_get')) && (WARN_SESSION_AUTO_START == 'true') ) {

if (ini_get('session.auto_start') == '1') {

$messageStack->add('header', WARNING_SESSION_AUTO_START, 'warning');

}

}

 

if ( (WARN_DOWNLOAD_DIRECTORY_NOT_READABLE == 'true') && (DOWNLOAD_ENABLED == 'true') ) {

if (!is_dir(DIR_FS_DOWNLOAD)) {

$messageStack->add('header', WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT, 'warning');

}

}

 

if ($messageStack->size('header') > 0) {

echo $messageStack->output('header');

}

?>

 

<!--

 

 

 

 

<? // ---- MANUFACTURERS

 

 

$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");

if ($number_of_rows = tep_db_num_rows($manufacturers_query)) {

 

echo '<table cellspacing=0 cellpadding=0 width=177 align=center> '.

tep_draw_form('manufacturers', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get')

.' <tr><td colspan=2><b>Search by manufacturers:</b></td></tr>

<tr><td height=2 colspan=2></td></tr>

<tr><td colspan=2>

';

 

$manufacturers_array = array();

while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {

$manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']);

$manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],

'text' => $manufacturers_name);

}

 

echo tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, (isset($HTTP_GET_VARS['manufacturers_id']) ? $HTTP_GET_VARS['manufacturers_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" class=se1') . tep_hide_session_id();

echo ' </td>

</form>

</table>

';

}

 

?>

 

 

-->

 

 

 

<table width=100% height=100% cellspacing=0 cellpadding=0 align="center" >

<tr><td class=he>

<table width=766 cellspacing=0 cellpadding=0 align="center">

<tr><td height=26 colspan=7 valign=bottom><img src=images/m06.gif width=577 height=17></td></tr>

<tr><td width=14></td>

<td><a href=<?=tep_href_link('index.php')?>><img src=images/m01.gif width=193 height=85 border=0></a><img src=images/m02.jpg width=237 height=85></td>

<td width=133 background=images/b04.jpg>

<table cellspacing=0 cellpadding=0>

<tr><td height=12 class=cu>Currencies:</td></tr>

<tr><td height=29 valign=top>

<? // CURRENCIES

 

echo tep_draw_form('currencies', tep_href_link(basename($PHP_SELF), '', $request_type, false), 'get');

 

reset($currencies->currencies);

$currencies_array = array();

while (list($key, $value) = each($currencies->currencies)) {

$currencies_array[] = array('id' => $key, 'text' => $value['title']);

}

 

$hidden_get_variables = '';

reset($HTTP_GET_VARS);

while (list($key, $value) = each($HTTP_GET_VARS)) {

if ( ($key != 'currency') && ($key != tep_session_name()) && ($key != 'x') && ($key != 'y') ) {

$hidden_get_variables .= tep_draw_hidden_field($key, $value);

}

}

 

echo tep_draw_pull_down_menu('currency', $currencies_array, $currency, 'onChange="this.form.submit(); " style="width:110px; font-size: 9px" ') . $hidden_get_variables . tep_hide_session_id();

echo '</form>';

 

?>

 

</td></tr>

<tr><td height=6 valign=top><img src=images/m03.gif width=133 height=1></td></tr>

<tr><td class=cu>now in your cart <a class=cl href=<?=tep_href_link('shopping_cart.php')?>><?=$cart->count_contents()?> items</a></td></tr>

</table>

</td>

<td><img src=images/m04.gif width=1 height=85></td>

<td width=125 valign=top>

<img src=images/m05.gif width=28 height=4 align=absmiddle><a href=<?=tep_href_link('specials.php')?> class=cu>Specials</a><br>

<img src=images/m05.gif width=28 height=4 align=absmiddle><a href=<?=tep_href_link('advanced_search.php')?> class=cu>Search</a><br>

<img src=images/m05.gif width=28 height=4 align=absmiddle><a href=<?=tep_href_link('contact_us.php')?> class=cu>Contact Us</a><br>

<img src=images/m05.gif width=28 height=4 align=absmiddle><a href=<?=tep_href_link('create_account.php')?> class=cu>Create an account</a><br>

<img src=images/m05.gif width=28 height=4 align=absmiddle><a href=<?php if (tep_session_is_registered('customer_id')) {

echo '<a href="';

echo tep_href_link(index.php, '', 'SSL');

echo '">Logout</a>';

} else {

echo '<a href="';

echo tep_href_link(login.php, '', 'SSL');

echo '">Customer Login</a>';

}?><br>

</td>

<td><img src=images/m04.gif width=1 height=85></td>

<td width=17></td>

<td width=45 valign=top>

<? // LANGUAGES

 

if (!isset($lng) || (isset($lng) && !is_object($lng))) {

include(DIR_WS_CLASSES . 'language.php');

$lng = new language;

}

 

$languages_string = '';

reset($lng->catalog_languages);

while (list($key, $value) = each($lng->catalog_languages)) {

$languages_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_LANGUAGES . $value['directory'] . '/images/' . $value['image'], $value['name'], '', '', 'vspace=1') . '</a><br>';

}

 

echo $languages_string;

 

?>

 

 

</td>

</tr>

</table>

<table width=766 cellspacing=0 cellpadding=0 align="center">

<tr><td width=14></td>

<td valign=top><img src=images/m10.gif width=193 height=31><br>

<a href=<?=tep_href_link('index.php')?>><img src=images/m11.gif width=193 height=29 border=0></a><br>

<a href=<?=tep_href_link('products_new.php')?>><img src=images/m12.gif width=193 height=27 border=0></a><br>

<a href=<?=tep_href_link('account.php')?>><img src=images/m13.gif width=193 height=26 border=0></a><br>

<a href=<?=tep_href_link('shopping_cart.php')?>><img src=images/m14.gif width=193 height=27 border=0></a><br>

<a href=<?=tep_href_link('checkout_shipping.php')?>><img src=images/m15.gif width=193 height=27 border=0></a>

</td>

<td><img src=images/m16.jpg width=282 height=180></td>

<td><img src=images/m17.gif width=263 height=14><br><a href=<?=tep_href_link('product_info.php','products_id=237')?>><img src=images/m18.jpg width=263 height=148 border=0></a><br><img src=images/m19.gif width=263 height=18></td>

<td width=14></td>

</tr>

</table>

<table width=766 cellspacing=0 cellpadding=0 align="center">

<tr><td width=222 valign=top>

<img src=images/m20.gif width=222 height=26 vspace=9><br>

 

 

 

 

 

 

 

<? // ---- CATEGORIES

 

function tep_show_category($counter) {

global $tree, $categories_string, $cPath_array;

 

if(!$tree[$counter]['level']){

 

$categories_string .= $categories_string ? '<img src=images/m22.gif width=222 height=1 vspace=5><br>' : '';

 

$categories_string .= '<img src=images/m21.gif width=47 height=6 align=absmiddle><a class=me href=';

 

if ($tree[$counter]['parent'] == 0) {

$cPath_new = 'cPath=' . $counter;

} else {

$cPath_new = 'cPath=' . $tree[$counter]['path'];

}

$categories_string .= tep_href_link('index.php', $cPath_new) . '>';

// display categry name

$categories_string .= $tree[$counter]['name'];

$categories_string .= '</a><br>';

 

}else{ // SUBCATEGORY

 

$categories_string .= '    ';

 

for($i=0;$i<$tree[$counter]['le vel'];$i++)

$categories_string .= '   ';

 

$categories_string .= '      - <a class=me style="font-weight:normal;font-color:red;" href=';

if ($tree[$counter]['parent'] == 0) {

$cPath_new = 'cPath=' . $counter;

} else {

$cPath_new = 'cPath=' . $tree[$counter]['path'];

}

$categories_string .= tep_href_link('index.php', $cPath_new) . '>';

// display category name

$categories_string .= $tree[$counter]['name'];

$categories_string .= '</a><br>';

}

 

if ($tree[$counter]['next_id'] != false) {

tep_show_category($tree[$counter]['next_id']);

}

}

 

 

 

define(TABLE_CATEGORIES, "categories");

define(TABLE_CATEGORIES_DESCRIPTION, "categories_description");

$categories_string = '';

$tree = array();

 

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

while ($categories = tep_db_fetch_array($categories_query)) {

$tree[$categories['categories_id']] = array('name' => $categories['categories_name'],

'parent' => $categories['parent_id'],

'level' => 0,

'path' => $categories['categories_id'],

'next_id' => false);

 

if (isset($parent_id)) {

$tree[$parent_id]['next_id'] = $categories['categories_id'];

}

 

$parent_id = $categories['categories_id'];

 

if (!isset($first_element)) {

$first_element = $categories['categories_id'];

}

}

 

//------------------------

if ($cPath) {

$new_path = '';

reset($cPath_array);

while (list($key, $value) = each($cPath_array)) {

unset($parent_id);

unset($first_id);

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

if (tep_db_num_rows($categories_query)) {

$new_path .= $value;

while ($row = tep_db_fetch_array($categories_query)) {

$tree[$row['categories_id']] = array('name' => $row['categories_name'],

'parent' => $row['parent_id'],

'level' => $key+1,

'path' => $new_path . '_' . $row['categories_id'],

'next_id' => false);

 

if (isset($parent_id)) {

$tree[$parent_id]['next_id'] = $row['categories_id'];

}

 

$parent_id = $row['categories_id'];

 

if (!isset($first_id)) {

$first_id = $row['categories_id'];

}

 

$last_id = $row['categories_id'];

}

$tree[$last_id]['next_id'] = $tree[$value]['next_id'];

$tree[$value]['next_id'] = $first_id;

$new_path .= '_';

} else {

break;

}

}

}

$categories_string .= '';

tep_show_category($first_element);

$categories_string .= '';

 

echo $categories_string;

?>

 

 

 

 

 

 

 

 

<img src=images/m23.gif width=222 height=26 vspace=9><br>

 

 

 

 

 

 

 

 

 

<? // SEARCH ?>

<table cellspacing=0 cellpadding=0 align=center>

<?=tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get')?>

 

<tr><td><?=tep_draw_input_field('keywords', '', 'size="20" maxlength="30" class=se') . tep_hide_session_id()?></td><td><input type=image src=images/m24.gif width=32 height=21 hspace=2></td></tr>

<tr><td colspan=2 height=25><a href=<?=tep_href_link('advanced_search.php')?> class=as>Advanced search</a></td></tr>

<tr><td colspan=2 height=25>All prices are subject to change!<br />

Prices exclude shipping and taxes!

</td></tr>

</form>

</table>

<? // END SEARCH ?>

 

 

</td><td class=mc>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...