Session Cookies

ChrisTERiS
ChrisTERiS used Ask the Experts™
on
I've the follow javascript function which store some criteria from my search form to cookies.
function saveParametersWithFilter(){
Set_Cookie( "category_filter", DG_gvv('category_filter'), 1);
Set_Cookie( "user_filter", DG_gvv('user_filter'), 1);
Set_Cookie( "location_filter", DG_gvv('location_filter'), 1);
Set_Cookie( "adtype_filter", DG_gvv('adtype_filter'), 1);
Set_Cookie( "title_filter", DG_gvv('title_filter'), 1);
Set_Cookie( "seller_filter", DG_gvv('seller_filter'), 1);
Set_Cookie( "status_filter", DG_gvv('status_filter'), 1);
Set_Cookie( "min_price_filter", DG_gvv('min_price_filter'), 1);
Set_Cookie( "max_price_filter", DG_gvv('max_price_filter'), 1);
Set_Cookie( "date_filter", DG_gvv('date_filter'), 1);
DG_saveParameters();
}

Open in new window


The problem is that this function store the data for ever. I tried many different ways to set the cookie life but I had no luck. Finally I used another function to erase the cookies:
function DG_resetSearch() {
eraseCookie("DG_parametersclassifieds_search");
eraseCookie("category_filter");	
eraseCookie("user_filter");
eraseCookie("location_filter");
eraseCookie("adtype_filter");
eraseCookie("title_filter");
eraseCookie("seller_filter");
eraseCookie("status_filter");
eraseCookie("min_price_filter");
eraseCookie("max_price_filter");
eraseCookie("date_filter");
DG_hss("rstsearch" + ac(),"none");
DG_closeSearch();
DG_Do ("resetsearch");
}

Open in new window

But I found difficulties to use it body onunload. Works with FF not with IE. Same (bad) luck I had using onbeforeunload.
I've hear that there are session only cookies in Javascript. I mean Cookies staying alive till the user will close the browser (but not moving from page to page).

So my questions are:
1.- Can someone tell me how I can modify these functions to work as session cookies?
....or....
2.- What I'm trying to do is to keep the search criteria active when someone clicks (eg a title from the list), goes to the record view page and then clicks the browser's back button. Only in this case I want to have the cookies active. In all other cases I want the cookies to be erased.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fixer of Problems
Most Valuable Expert 2014
Commented:
Here's some info on javascript and cookies: http://www.w3schools.com/js/js_cookies.asp  "Set_Cookie" is not a built-in javascript function so you must have that as function somewhere else in your code.  A 'session cookie' in the browser is one without an expiration date.  It expires when the browser is completely closed.  You can change the info with javascript but you can't actually 'expire' or delete it.  That must be what your 'eraseCookie' function does.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial