Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

sessions and the browser back button


applelinks

Recommended Posts

HI

 

We have set up a static PHP page with several products hard coded using this code

 

<?php echo '<p><a href="' . tep_href_link('index.php', 'action=buy_now&products_id=2742') . '"><img src="/includes/languages/english/images/buttons/button_in_cart.gif"></a></p>'; ?>

 

The code works fine, the customer clickt the add to cart button and the item is added to the cart

 

the problem we are having is when a customer uses the back button on their browser and adds another product to the cart the session ID changes and the first product that was added to cart is no longer there.

 

Is there any way to keep the session ID if the customer user the back button.

 

 

our session settings are

Force Cookie Use - false .............and we would like not to fore cookies

Recreate Session - true

 

 

Thanks in advance for your time

 

Joe

----------------------------

Long Island, New York

Link to comment
Share on other sites

Also Compared mys sessions.php file to a clean install and found the my sessions file did not include the foollowing

	global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS;

$sane_session_id = true;

if (isset($HTTP_GET_VARS[tep_session_name()])) {
  if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_GET_VARS[tep_session_name()]) == false) {
	unset($HTTP_GET_VARS[tep_session_name()]);

	$sane_session_id = false;
  }
} elseif (isset($HTTP_POST_VARS[tep_session_name()])) {
  if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_POST_VARS[tep_session_name()]) == false) {
	unset($HTTP_POST_VARS[tep_session_name()]);

	$sane_session_id = false;
  }
} elseif (isset($HTTP_COOKIE_VARS[tep_session_name()])) {
  if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_COOKIE_VARS[tep_session_name()]) == false) {
	$session_data = session_get_cookie_params();

	setcookie(tep_session_name(), '', time()-42000, $session_data['path'], $session_data['domain']);

	$sane_session_id = false;
  }
}

if ($sane_session_id == false) {
  tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false));
}

----------------------------

Long Island, New York

Link to comment
Share on other sites

all your php pages should include application_top.php this is where the session is generated.

 

 

Hi

 

On line 13 we have the following

 

require('includes/application_top.php');

 

I just noticed that evertimg the page refreshes the session ID changes

 

Thanks

Joe

----------------------------

Long Island, New York

Link to comment
Share on other sites

Hi

 

On line 13 we have the following

 

require('includes/application_top.php');

 

I just noticed that evertimg the page refreshes the session ID changes

 

Thanks

Joe

does it happen with all osc pages or the ones you created only?

Link to comment
Share on other sites

does it happen with all osc pages or the ones you created only?

 

 

Nice catch!

 

It happens on all the pages that you land on. if there is no session ID in the url it will change the Session ID in the links on the page when you refresh

 

Do you know a way to fix this?

 

 

Thanks

 

 

Joe

----------------------------

Long Island, New York

Link to comment
Share on other sites

there are 2 files to begin checking.

catalog\includes\configure.php

catalog\includes\application_top.php

 

For the application_top you could backup the one you have and try the vanilla one

http://www.oscommerce.com/solutions/downloads

 

For the configuration file check the default settings (not for the domain, paths) but like the persistent connections (should be false) and also set the sessions to be stored in the database. ie:

 

  define('USE_PCONNECT', 'false'); // use persistent connections?
 define('STORE_SESSIONS', 'mysql'); // leave empty '' for default handler or set to 'mysql'

Link to comment
Share on other sites

also set create new session as false and chek.

 

Satish

Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

Link to comment
Share on other sites

there are 2 files to begin checking.

catalog\includes\configure.php

catalog\includes\application_top.php

 

For the application_top you could backup the one you have and try the vanilla one

http://www.oscommerce.com/solutions/downloads

 

For the configuration file check the default settings (not for the domain, paths) but like the persistent connections (should be false) and also set the sessions to be stored in the database. ie:

 

  define('USE_PCONNECT', 'false'); // use persistent connections?
 define('STORE_SESSIONS', 'mysql'); // leave empty '' for default handler or set to 'mysql'

 

 

I check both files

 

catalog\includes\configure.php

has the correct settings

 

catalog\includes\application_top.php

is almost the same as a clean install, just a few lines of code for some add ons

 

I'm stumped

----------------------------

Long Island, New York

Link to comment
Share on other sites

Where would i look for this setting?

 

Thanks

 

joe

 

 

HI

 

Incase anyone wants to know what the proble was......... very stupid. I has the cookie nane set wrong in /include/config.php

 

thanks

 

Joe

----------------------------

Long Island, New York

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...