firstandthird / cookie-monster Goto Github PK
View Code? Open in Web Editor NEWJavascript Cookie Library
License: MIT License
Javascript Cookie Library
License: MIT License
When I try to set an object as a cookie value, it fails. Should I use JSON myself or are you planing to add support for this in the library?
var Monster = requirejs('monster')
:)
I have a standard Safari setup.
Cookies from my Rails application are setting properly.
Safari v 6.0.2
No errors in console.
Cookies are not being set.
Not sure what to look for or to help debug, but let me know and I'll try and get you whatever information you need.
Simple question... Why did you use v (here)? Could you not just set the object without the v? Or is it in case you need to store other values? If so, you're not, so why?
Curious :)
Can you actually use this with ender? It's tagged with ender however there's no actually additions to the ender object ($) that can be used. I don't see any integrations in the code either, or anyway at all how to use it.
Now you have cookie time only in nr of days, you could enhance that a little.
The old "days" parameter is renamed to "period".. (it defaults back to the original days).
Now the period can be "4d" or "8h" or "1d4h" or "12" for just 12 days
if (typeof period === "number") {
period = period.toString()+"d"
}
if (typeof period === "string") {
var addtime=0, t, i, reg = /([0-9]{1,3}[d|h])/g, arr = period.match(reg);
for (i=0;i<arr.length;i++) {
t=arr[i].slice(-1);
switch(t) {
case 'h':
addtime += (parseInt(arr[i]) * 60 * 60 * 1000)
break;
case 'd':
default:
addtime += (parseInt(arr[i]) * 24 * 60 * 60 * 1000)
break;
}
}
date.setTime(date.getTime() + addtime);
expires = "; expires=" + date.toUTCString();
}
This is a nice way to do cookies, but I need to set the domain explicitly sometimes:
diff --git a/lib/monster.js b/lib/monster.js
index daae4c6..c6d61e6 100644
--- a/lib/monster.js
+++ b/lib/monster.js
@@ -1,10 +1,11 @@
var monster = {
sensible to replace with encodeURIComponent / decodeURIComponent ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.