Cookies are saved with form id which isn't unique to sessions
wmpnj opened this issue · 5 comments
Any way to add the session id to the cookie along with the form id? As is, my first test shows a separate user will see the saved data from the first user and this is not acceptable behavior for our app.
Thanks
Hi, Ben:
Thought of that and was hoping to go without a lot of modifications to the app. As-is, this will only affect someone who shares a workstation (rotating shifts0 or a kiosk. I think we can live with that. What I’m attempting to do now is save the form data after an AJAX call is used to populate some of the elements. I’m using the $(‘#form1).sayt({‘savenow’ : true}); but it doesn’t appear to save all the elements (two dropdowns). I’m also using the ‘erase’ : true when a reset button is clicked, but two input boxes appear to be repopulated after the reset. Other than that, things have tested out very well – thanks for the plugin, greatly appreciated!!
Bill
From: Ben [mailto:notifications@github.com]
Sent: Wednesday, July 09, 2014 1:51 PM
To: BenGriffiths/jquery-save-as-you-type
Cc: wmpnj
Subject: Re: [jquery-save-as-you-type] Cookies are saved with form id which isn't unique to sessions (#6)
Hi,
There's no way to do this directly, however you could store the session ID in a hidden form variable, and check it before restoring the form data.
—
Reply to this email directly or view it on GitHub #6 (comment) . https://github.com/notifications/beacon/6406308__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyMDU1ODI2MywiZGF0YSI6eyJpZCI6MzY2MjkwNTF9fQ==--f1360e6f4d90e26c7c54a9de69b6df7d912b93b8.gif
Haha, you got there before I'd deleted my reply - the only out of the box way I can think of doing is if you appended the session ID to the form ID's - it's not a very elegant solution though. I'll have a think about adding a feature for session IDs with the cookies.
I don’t think it’s so much session ID as user ID. The session will not persist for 3 days for example. So, when instantiating, we’d do something like { ‘Id’ : ‘11100000987’ ]. I looked at js-cookie to see if I could manipulate the names, but it did not appear to be a quick solution and the more I thought of that, the more I wanted to avoid named cookies. The best, IMHO, approach would be one object whose id attribute was the id of the user.
Just thoughts for the future should others desire something similar. For now, I think we’re ok. We don’t have kiosks and if someone does share a desk, then they are sharing similar roles, responsibilities and data.
Bill
From: Ben [mailto:notifications@github.com]
Sent: Thursday, July 10, 2014 5:13 AM
To: BenGriffiths/jquery-save-as-you-type
Cc: wmpnj
Subject: Re: [jquery-save-as-you-type] Cookies are saved with form id which isn't unique to sessions (#6)
Haha, you got there before I'd deleted my reply - the only out of the box way I can think of doing is if you appended the session ID to the form ID's - it's not a very elegant solution though. I'll have a think about adding a feature for session IDs with the cookies.
—
Reply to this email directly or view it on GitHub #6 (comment) . https://github.com/notifications/beacon/6406308__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyMDYxMzU5OSwiZGF0YSI6eyJpZCI6MzY2MjkwNTF9fQ==--140b107c0460a6adf2764f9068d49599e70e33f2.gif
Unrelated question: any thoughts on why sayt is not saving/restoring select list options? Even if I choose a value from a dropdown, then enter some text into an input textbox, the select value is not being restored.
Thanks,
Bill
From: Ben [mailto:notifications@github.com]
Sent: Thursday, July 10, 2014 5:13 AM
To: BenGriffiths/jquery-save-as-you-type
Cc: wmpnj
Subject: Re: [jquery-save-as-you-type] Cookies are saved with form id which isn't unique to sessions (#6)
Haha, you got there before I'd deleted my reply - the only out of the box way I can think of doing is if you appended the session ID to the form ID's - it's not a very elegant solution though. I'll have a think about adding a feature for session IDs with the cookies.
—
Reply to this email directly or view it on GitHub #6 (comment) . https://github.com/notifications/beacon/6406308__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyMDYxMzU5OSwiZGF0YSI6eyJpZCI6MzY2MjkwNTF9fQ==--140b107c0460a6adf2764f9068d49599e70e33f2.gif
I think I found a way to provide unique names despite Visual Studio refusing to build my app with a form identifier that isn’t static.
We use an EDIPI – electronic data interchange personal identifier- to uniquely identify users. If I try the following, my build fails:
”If I leave it at <form id=”CreateCaseForm” and then after the DOM has loaded use jQuery to change the id, like this:
$('#CreateCaseForm').attr('id', 'CreateCaseForm<% =user.getEdiPI() %>');
And use that same id everywhere I reference the form, i.e.
$('#CreateCaseForm<% =user.getEdiPI() %>').sayt();
Then the app builds and deploys and at runtime the unique identifier is part of the form id and thus the cookie name.
This appears to work in my local testing.
HTH,
Bill
From: Ben [mailto:notifications@github.com]
Sent: Thursday, July 10, 2014 5:13 AM
To: BenGriffiths/jquery-save-as-you-type
Cc: wmpnj
Subject: Re: [jquery-save-as-you-type] Cookies are saved with form id which isn't unique to sessions (#6)
Haha, you got there before I'd deleted my reply - the only out of the box way I can think of doing is if you appended the session ID to the form ID's - it's not a very elegant solution though. I'll have a think about adding a feature for session IDs with the cookies.
—
Reply to this email directly or view it on GitHub #6 (comment) . https://github.com/notifications/beacon/6406308__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyMDYxMzU5OSwiZGF0YSI6eyJpZCI6MzY2MjkwNTF9fQ==--140b107c0460a6adf2764f9068d49599e70e33f2.gif