Post by barns101 » Fri Jun 06, 2008 8:55 pm

I've done a search and can't find this bug mentioned anywhere else. I've found a bug with coupon codes whilst testing OpenCart v0.7.7

If a coupon code is entered by customer A but he then logs out without paying, and customer B logs in without closing the web browser, customer B gets customer A's coupon code automatically applied to his order. Closing the browser in between visits resolves this.

I've not looked into the code but I would guess that the user's session is not destroyed when he logs out, rather his "status" is changed from "logged in" to "logged out" and so the coupon code (and possibly his cart contents) are passed on to the next shopper that logs in after him (without closing the web browser).

Newbie

Posts

Joined
Fri Jun 06, 2008 8:27 pm

Post by Luvz2drv » Sat Jun 07, 2008 2:45 am

the coupon code is stored via the session. 

Global Moderator

Posts

Joined
Fri Mar 21, 2008 10:58 am

Post by bruce » Sat Jun 07, 2008 11:41 am

To fix this by clearing up the session when the user logs out, modify the file catalog\controller\account_logout.php to add the session_destroy() call as shown below.

Code: Select all

		if ($customer->isLogged()) {
			$customer->logout();
			$cart->clear();
			session_destroy();
			$response->redirect($url->ssl('account_logout'));
		}

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by hm2k » Sat Jun 07, 2008 6:27 pm

barns101 wrote: I've not looked into the code but I would guess that the user's session is not destroyed when he logs out, rather his "status" is changed from "logged in" to "logged out" and so the coupon code (and possibly his cart contents) are passed on to the next shopper that logs in after him (without closing the web browser).
The session should automatically time out after 3600 seconds. However, as bruce said it should really be correctly destroyed on logout.

You may also wish to place the destroy here:

"catalog/library/session/session.php"

Code: Select all

  	function destroy($session_id) {
		$this->database->query($this->database->parse("delete from session where session_id = '?'", $session_id));
		session_destroy();
    	return $this->database->countAffected();
  	}

UK Web Hosting


User avatar
Global Moderator

Posts

Joined
Tue Mar 11, 2008 9:06 am
Location - UK

Post by Luvz2drv » Sat Jun 07, 2008 10:43 pm

echo in the thread i think

Global Moderator

Posts

Joined
Fri Mar 21, 2008 10:58 am

Post by barns101 » Mon Jun 09, 2008 5:52 pm

Thanks guys, that fixed it.

Great looking cart so far.  :)

Newbie

Posts

Joined
Fri Jun 06, 2008 8:27 pm
Who is online

Users browsing this forum: No registered users and 1 guest