Session related issues with the cart

  • Posts: 15
  • Thank you received: 0
9 years 3 months ago #212597

-- HikaShop version -- : 2.2.2
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.4.37
-- Browser(s) name and version -- : Chrome 44.0.2403.157 m

Hi,

I am facing session related problems and a search on the issue has led me to the following forum post which seems to be the problem that I am facing:

hikashop.com/forum/checkout/868584-cannot-empty-checkout.html

Just to clarify, my specific problem is as follows:

  • I add some products to the cart and do not proceed with the checkout
  • Now if I revisit the site say, the next day (after the Joomla session has expired), without having closed my browser, I am not able to delete the products added the previous day. Also, if I now refresh the page, the cart shows up as empty but on adding a new product, I get to see the products added on the previous day. Proceeding to checkout gives me a message that the cart is empty.
  • The only way to set things right is to clear the browser cache after which things work as expected.

On a related note another session related problem that I have noticed is as follows:
  • Visit the site so as to start a new user session.
  • Now delete all the carts from the Hikashop backend on the server.
  • Now try adding some products to the cart on the client end. You will see the products being added to the cart but this cart does not show up on the list of carts in the Hikashop backend on the server. Also, you cannot delete these products from the cart on the client end.
  • The only solution is to clear the browser cache on the client end so that a new session gets started.

I understand that the problems described by me are similar to what is described in the forum post that I referred to above. I also believe that you have fixed these issues in a later version of Hikashop.

Unfortunately, I have inherited the current site from a previous developer and I cannot risk a Hikashop update because of the fact that the code is heavily customized.

I will greatly appreciate if you can tell me what changes to make in the Hikashop files of my version, which will solve these issues.

Thanks in advance for your help and cooperation.

With warm regards

Last edit: 9 years 3 months ago by rdpaul.

Please Log in or Create an account to join the conversation.

  • Posts: 82910
  • Thank you received: 13379
  • MODERATOR
9 years 3 months ago #212646

Hi,

Two easy things you can try:
1. change the "session handler" setting of the Joomla configuration. It can sometimes help if the issue is related to the user session
2. deactivate the cache setting of the Joomla configuration and the Joomla system cache plugin via the Joomla plugins manager. This will prevent issues related to the cache.

We didn't really "fix" these issues. Instead we circumvented them by simply clearing off the cache of Joomla any time the cart is updated. Turn off the cache completely should thus do the same.

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
9 years 3 months ago #212700

Hi Nicolas,

Thanks for your reply.

I forgot to mention in my earlier post that the cache on my site is turned off and the System Cache plugin is unpublished. The session lifetime has been set to 120 minutes.

Since the site is under development, when I come back to resume work the next day, the site is invariably open in the browser (with the Joomla session expired) and when I attempt to add anything to the cart in this situation I always run into problems that I described in the earlier post.

What it seems to my limited understanding is that when the session has expired and the user has not closed the browser then the session cookies persist on the user end. Now if a product is added to the cart, the existing session cookie is used to establish a connection with the non-existent session on the server which causes the problem.

I am using the Smartaddons Mini Cart on my site and this module uses Ajax to communicate with the server to update the cart. I noticed that whenever there is a session problem, the response from the server as shown by the SJ Minii Cart is able to indicate that there is a problem (I remember that the cart total is received as "Free" in such cases). If I don't find any other solution to this issue then what I intend to do is as follows:

  • when an item is added to the cart, I will look out for a flawed response from the server (indicating a session problem) and in that case I will alert the user that the session has expired
  • use Javascript to clear the site's session cookies on the user end followed by a page refresh to establish a new session
  • since Joomla's session cookie has the HttpOnly flag set, as it is, Javascript cannot be used to delete such cookies so a core hack will be needed in Joomla's files to remove the HttpOnly flag

I am assuming that the above will sort out these issues but I am hoping that you can suggest a much cleaner solution to the problem.

In particular, can you let me know how I can patch code to clear the Joomla session every time a product is added to the cart and also to establish a new session when the old one has expired.

Thanks again for your help.

With regards.

Please Log in or Create an account to join the conversation.

  • Posts: 26159
  • Thank you received: 4028
  • MODERATOR
9 years 3 months ago #212817

Hi,

There is no need to clear the Joomla session ; the session is what contain the cart, the user, etc. Clearing will just destroy everything, so that's really not a good idea.
The patch that Nicolas was talking about is for the cache clear, but if you're sure that you do not have any cache system, you do not need that patch.

The session is managed by Joomla, I really don't know what we can do to fix that, because if the session has expired, the session is just lost and you will receive a new one.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
9 years 2 months ago #212835

Hi Jerome,

Thanks for your reply.

I was not talking about clearing the Joomla session - rather I was talking of clearing the session cookies that remain on the user's end even after the Joomla session has expired on the server.

Anyways, I understand your point of view on this and will try to figure out the best that can be done in this situation.

With thanks and regards.

Please Log in or Create an account to join the conversation.

Time to create page: 0.061 seconds
Powered by Kunena Forum