Focal Point
cookie deletion

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6181098331

September 14, 2005, 09:35 PM
paw
cookie deletion
Hi -
I was wondering if anyone has ever run into a situation like the following (I'll try to make it breif):
When you log onto our application, we store a user id and other variables in a cookie. Throughout the app, we access those variables via the cookie. There is one focexec that we run where when we process about 20 records, it works fine. (The fex called is in a loop from 1 to the number of records chosen and inserts new rows into a DB2 table) If we process more than 20 records the loop fex still works, but when it comes back to display the HTMLFORM page for the output - for some reason it deletes the cookie and it cannot find the variables that we need for the page.
What I do not understand is why the cookie is being deleted. My first guess is that it has something to do with the size of what we are processing because it works perfectly fine on a smaller amount of records.
I have tried many different things even creating the cookie again right before the page is loaded, but that still doesn't work - it can't find it.
Just wondering if anyone has run into a similar problem with cookies.

Thanks.
September 15, 2005, 03:12 PM
Francis Mariani
Could it have something to do with the date/time the cookie expires?


This JS function creates a cookie:
// Sets the value of a cookie specified by "name" ------------------------------
function fnSetCookie(name, value, expires, path, domain, secure)
{
var argv = fnSetCookie.arguments;
var argc = fnSetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;

document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
This JS code creates a variable for Expiry Date (probably could be done simpler):
// Set up Cookie Expiry Date
var v100Days = (24 * 60 * 60 * 1000) * 100; // 100 Days in milliseconds
var vExpDate = new Date(); // Create a Current Date object
vExpDate.setTime(vExpDate.getTime() + v100Days); // Add 100 days to Current Date
This JS code calls the create cookie function:
fnSetCookie('gcr_login','AUTO',vExpDate,'/');
I hope this helps.

This message has been edited. Last edited by: <Maryellen>,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 16, 2005, 01:26 PM
paw
Thanks for the info Francis, but I don't think it has to do with expiration. When we create the cookie, we don't set an expiration date so the default is that the cookie is stored in memory and it expires when the browser closes. I did experiment with making the cookie expire at the end of the year so that I could see the cookie on my PC. It still deleted the cookie even when it was in my Temporary Internet Files directory
September 16, 2005, 01:48 PM
Tony A
Paw,

If you let the default of timeout on browser closure, could your problem be down to cookie expiration owing to lengthy nil response from the server? i.e. Browser sitting there waiting for a response from the server (which is where your loop is taking place) and thinking "they've forgotten me" and deleting the cookie?

You could always try and set the expiry date/time to something that will exceed the worse case scenario of your requests, to see if that helps?
September 16, 2005, 08:18 PM
paw
Tony, thanks - that is something to consider. I didn't know that if the server is not getting any response it may delete the cookie - good to know. The looping is happenng on the mainframe side so it is not sending anything to the server until it is done.

However, I did try setting an expiration date and the same thing happened. For example, I set the expire date to the last day of the year (12-31-2005). Before executing the looping, I could see the cookie in my Temp Internet files folder. After the looping finished and it came back to the HTML page to display - cookie was gone.
September 30, 2005, 08:59 PM
paw
Thanks to those who responded. FYI for anyone else who may come across this situation. We use dialogue manager amper (&) variables in the application. What we didn't know is that those amper are stored in a cookie. In a loop we have, we stored quite a bit of data in an amper array variable. The variable was causing the cookie to go over the 4K cookie size limit, thus deleteing the cookie.