Comments (13)
I've noticed this as well. If EDS is enabled, the cart won't be cleared even for regular Koha items.
It looks like the cart info is being stored in bib_list cookies AND in local storage, but I don't think they're consistently updated.
At the moment, my cart says there are 18 items in it when there are actually 2. And even those two were actually from a previously cleared session...
from edsapi-koha-plugin.
After doing an "Empty and clear", I now have "-1" items in my cart... although after I tried to open that -1 item, it reset everything seemingly correctly...
from edsapi-koha-plugin.
Ahhh, I see the problem with the "18" items.
It's because of "jbib_list.length-1" (https://github.com/ebsco/edsapi-koha-plugin/blob/master/Koha/Plugin/EDS/js/EDSScript.js#L102). That's not getting the length of an array. It's getting the length of the string. So jbib_list is "12345678/901234567/" with a length of 19 - 1 = 18.
This goes back to wizzyrea's original problem... the cart shouldn't preserve data from previous sessions.
I assume local storage is needed for using the cart with Discovery, but perhaps another cookie should be used to determine if it's a new session or an on-going session...
from edsapi-koha-plugin.
Going to open some new issues and stop hijacking wizzyrea's...
from edsapi-koha-plugin.
Related to this problem... if you remove all items from the cart using the "Remove" link from within the cart, you'll always have 1 item left in local storage.
The cart will say there are 0 items if you click on it, and the search results will look OK, but if you re-open the cart or close the window and re-open it, the cart will re-gain that 1 item.
from edsapi-koha-plugin.
The more I think about this, the more I don't understand why "bib_list" is stored in local storage... will chat to Alvet about this today...
from edsapi-koha-plugin.
Apparently these 2 lines caused the problem.
//if (basketcount != jbib_list.split('/').length - 1)
//updateBasket(jbib_list.length -1);
This should be fixed in the latest versions of the plugin but will keep this open to allow for testing and confirmation.
from edsapi-koha-plugin.
Sorry, Alvet, but that wasn't the problem in this issue. I hijacked this issue with the count, but the actual problem is that the local storage is preserved between browser sessions. Typically, the Koha cart is emptied when a browser session ends because the cookie is destroyed, and that's the desired behaviour especially in regard to user privacy.
I think it would be wise to consider using sessionStorage instead of localStorage: http://stackoverflow.com/questions/18633715/remove-localstorage-on-closing-browser-javascript
from edsapi-koha-plugin.
You are right; data should be removed on unload. I am using jStorage as it manages cross-browser (no HTML5) and it is set to retain for 30 minutes (by default but configurable) after which it expires but I’ll look at something that clears this data on unload or something similar.
$.jStorage.set('edsKnownItems',JSON.stringify(data),{TTL:edsConfig.cookieexpiry_60_1000})
from edsapi-koha-plugin.
The default isn't 30 minutes. The default is eternity because the default value of cookieexpiry is an alphanumeric string and not a number. The name cookieexpiry seems to be a misnomer as well, since it's really local storage expiry rather than cookie expiry...
I've been looking at the TTL value more...
If the bib_list expires and then you close the browser, the cart will be empty when you re-open it because you won't have anything in local storage.
Otherwise, it looks like EDSScript.js will stuff the contents of localStorage's "bib_list" into the document cookie... whether that's for /cgi-bin/koha or /plugin/Koha/Plugin/EDS/opac depending on what page is visited.
By the way, if you set the expiry value too low, the cart won't work, because the local storage "bib_list" is only being set when in the opac-basket.pl.
The following lines should be used in the search results but they're only called in the opac-basket.pl specific block.
$('.addtocart').click(function () {
});
$('.cartRemove').click(function () {
});
from edsapi-koha-plugin.
Actually, sorry, that bit about the cart not working because of the expiry isn't quite right.
What I meant was... the local storage "bib_list" doesn't get set without visiting the basket. So if you add a few items to the cart, and then go to "Home" or any regular Koha page, your items won't appear in the cart because they weren't in local storage to be sucked up and stuffed into the cookie.
They'll only appear elsewhere in Koha if you visit the opac-basket.pl... and then only if the expiry doesn't destroy them first.
from edsapi-koha-plugin.
Personally, I'm starting to wonder if the regular "bib_list" cookie has a path of "/cgi-bin/koha" by intention or by accident. My guess would be that it's unintentional.
The majority of cookies in Koha use the root path, as they're set by CGI.pm which uses a default root path. The cart uses basket.js which uses window.document.cookie which uses the path of the document by default... which is "/cgi-bin/koha". If we change that to use the root path instead... we could spare a lot of grief.
from edsapi-koha-plugin.
This has been fixed in the newer version of the plugin.
I've updated to make sure that cookies set are Path cookies, and stopping the use of jStorage for the cart.
from edsapi-koha-plugin.
Related Issues (20)
- Can't locate object method "create_message_headers" via package "Koha::Email" error when sending email from the Cart HOT 2
- Results not updated after logging in HOT 2
- 21.05 version of plugin does not start on Koha 21.05 HOT 5
- eds-detail.pl needs to be updated for Bootstrap in 21.05+
- Plugin doesn't appear at Koha 21.11 and produces 500 error HOT 3
- Plugin will not start in Koha 21.11 HOT 2
- Plugin does not include a en.inc file
- Cannot send opac baskets in Koha 21.11 HOT 7
- 500 Error when refreshing session token HOT 9
- SetEDS() and SetKoha() functions attempt to call jQuertUI's autocomplete
- Plugin not constructing URLs correctly in 22.11.08 HOT 5
- Cannot download cart in Koha 22.11
- Cannot send cart from OPAC in 22.11
- Issues loading plugin in IE, EDGE, Safari HOT 2
- Cannot send basket with Koha 19.05 & plugin 19.05009 HOT 1
- Out of date templates with Koha 20.11 HOT 5
- Search select delayed population can cause user confusion HOT 5
- README.md appears to be incorrect regarding versions HOT 3
- Using Github's "Releases" functionality HOT 2
- Use Koha's REST API instead of relying on altered Apache configuration HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edsapi-koha-plugin.