-
Notifications
You must be signed in to change notification settings - Fork 0
Cookie
In Quickforms App, the cookie is stored in and read from local storage of client. Here is more information about local storage.
The functions that set and get cookie are located in the helper/helper.js file.
setCookie function:
c_name is the key you want to store in cookie.
value is the value of the key.
exdays is not used in the function, and will be removed in later version. Currently you could pass any variable in.
The function will store the key value pair in the local storage. And every time the app called this function, the cookie's expiration time will extend one hour, if the expiration time is less than one hour, to avoid relogin when user link to another page while the cookie is expired.
window.setCookie = function(c_name,value,exdays)
{
var app_c_name = quickforms.app+"_"+c_name;
localStorage.setItem(app_c_name, value);
var today = new Date();
var expDay = today.getTime() + 3600*1000;
var app_expDay = quickforms.app+"_expDay";
var oldExpDay = localStorage.getItem(app_expDay);
//If the cookie [appName]_expDay is null or will expire in one hour, extend the expiration time.
if(isNull(oldExpDay)||oldExpDay<expDay){
localStorage.setItem(app_expDay,expDay);
}
}
getCookie function:
c_name is the key you want to store in cookie.
The function will return the value of c_name in cookie.
window.getCookie = function(c_name)
{
var app_c_name = quickforms.app+"_"+c_name;
return localStorage.getItem(app_c_name);
return '';
}
setCookieExp function
exdays is the expiration day, unit is day.
The function will set the cookie's expiration time. Because different from the traditional cookie, the local storage has no expiration setting. So we added a expiration key value pair into the cookie to set the expiration time which is now used in access control.
window.setCookieExp = function(exdays)
{
var today = new Date();
var expDay = today.getTime() + exdays*24*3600*1000;
var app_expDay = quickforms.app+"_expDay";
localStorage.setItem(app_expDay,expDay);
}
checkCookieExp function
The function is used to check the cookie is expired or not. It will return a boolean value. True is expired.
window.checkCookieExp = function()
{
var app_expDay = quickforms.app+"_expDay";
var expDay = localStorage.getItem(app_expDay);
var today = new Date();
today.setHours(0,0,0,0);
if(!isNull(expDay)&&expDay>=today.getTime()){
return false;
}else{
return true;
}
}
-
Quickforms Basics
-
Tutorials
- Setup Tutorials
- App Development Tutorials
-
Assignments
-
Project
-
Applications
-
Quickforms Advanced
- Project With Database
- Advanced Setup
- HealthApp with Database
- Source Control
- Joining the Team
- Cordova Native Application
- Miscellaneous
- Project With Database
-
-
Form Controls
-
App Controls
-
Report Controls
-
Server Controls
-
Quickforms DAO
-
Email Notification
-
Migrating QuickForms3(Test Server) to QuickForms(Production-Server)