Avatar of ChrisTERiS
ChrisTERiS
 asked on

Session Cookies

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.
JavaScript

Avatar of undefined
Last Comment
Jagdish Devaku

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Dave Baldwin

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Jagdish Devaku

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes