Author Topic: SOLUTION: "Clear Cart" and "Logout" Links in Virtuemart 1.1.4  (Read 6503 times)


  • Beginner
  • *
  • Posts: 49
After searching through dead thread after dead thread - finding that people were trying to work out overcomplicated solutions for two cool features.

Logout Button / Link:

"index.php?option=com_user&task=logout&return=[BASE64 encrypted URL]"

Clear Cart / Empty Cart Link:

"index.php?page=shop.cart_reset&option=com_virtuemart&return= [BASE64 encrypted URL]"

I wanted these links at the bottom of minicart.tpl.php - but they can be put anywhere and will have the same basic functionality. I encrypted my %root%/index.php as the return URL.


  • Jr. Member
  • **
  • Posts: 209
Re: SOLUTION: "Clear Cart" and "Logout" Links in Virtuemart 1.1.4
« Reply #1 on: May 19, 2010, 17:12:34 pm »
Do you know of any way to get this to work for the hidden account used when the customer does not want to create an account.

I have verified that this does work when a normal registered user, but I am trying to use the optional account registration (and choosing Not to create an account) for taking phone orders. I inserted the link on the Thank you page, so when we are done we would click on it to log out the hidden user. Right now, it redirects to the home page, but the hidden user is not logged off. We can add something to the cart, and VM still thinks the previous user is logged in.

Any ideas?



  • Beginner
  • *
  • Posts: 6
Re: SOLUTION: "Clear Cart" and "Logout" Links in Virtuemart 1.1.4
« Reply #2 on: February 02, 2011, 03:22:21 am »
I ended up hacking the front end user component to delete all site cookies before performing the logout redirect. I'm sure if you were less lazy than me you could come up with a non-core hack to achieve the same thing.

Open up the controller file for the user component: /components/com_user/controller.php

Find line 182 (approximately).

Insert the following code which will delete all site cookies

            if (isset($_SERVER['HTTP_COOKIE'])) {
            $cookies = explode(';', $_SERVER['HTTP_COOKIE']);
            foreach($cookies as $cookie) {
               $parts = explode('=', $cookie);
               $name = trim($parts[0]);
               setcookie($name, '', time()-1000);
               setcookie($name, '', time()-1000, '/');

This worked for me because my site isn't using any other cookies (that I am aware of). It might require adjusting if you rely on any other cookies.

I found there are two cookies that affect the login . one is called 'virtuemart' while the other one has a random name like '8516949bd35844e7ad07e0acc79198d5' which might be the session id or something?

I hope this helps somebody out there.