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
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo