10 examples of 'createcookie' in JavaScript

Every line of 'createcookie' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
468function createCookie(name, value, days) {
469 days = days || 90;
470 var date = new Date();
471 date.setTime(date.getTime()+(days*24*60*60*1000));
472 var expires = "; expires="+date.toGMTString();
473 doc.cookie = name+"="+value+expires+"; path=/";
474}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

25function createCookie(name, value, days)
26{
27 var date, expires;
28
29 if ( days )
30 {
31 date = new Date();
32 date.setTime(date.getTime()+(days*24*60*60*1000));
33 expires = "; expires="+date.toGMTString();
34 } else
35 {
36 expires = "";
37 }
38
39 document.cookie = name+"="+value+expires+"; path=/";
40}
254function createCookie(name,value,days) {
255 /**
256 if (days) {
257 var date = new Date();
258 date.setTime(date.getTime()+(days*24*60*60*1000));
259 var expires = "; expires="+date.toGMTString();
260 } else {
261 expires = "";
262 } document.cookie = name+"="+value+expires+"; path=/";
263 **/
264}
31function createCookie(c, d, e) {
32 var a = '';
33 if (e) {
34 var b = new Date();
35 b.setTime(b.getTime() + (e * 1000));
36 a = '; expires=' + b.toGMTString();
37 }
38
39 document.cookie = c + '=' + d + a + ';domain=.gfycat.com;path=/';
40}
66function createCookie(name,value)
67{
68 var days = 100;
69
70 var date = new Date();
71 date.setTime(date.getTime()+(days*24*60*60*1000));
72 var expires = "; expires="+date.toUTCString();
73
74 document.cookie = name+"="+value+expires+"; path=/";
75}
33function createCookie(
34 name: string,
35 value: string,
36 options: CookieSerializeOptions,
37): Cookie {
38 return {
39 name: name,
40 expires: options.expires,
41 maxAge: options.maxAge,
42 secure: options.secure,
43 httpOnly: options.httpOnly,
44 domain: options.domain,
45 value: value,
46 path: options.path,
47 }
48}
13function createCookie(name, value, days) {
14 let date
15 let expires;
16
17 if (days) {
18 date = new Date();
19 date.setTime(date.getTime() + (days*24*60*60*1000));
20 expires = `; expires=${date.toGMTString()}`;
21 } else {
22 expires = "";
23 }
24 document.cookie = `${name}=${value + expires}; path=/`;
25}
97function createCookie(name, value, days) {
98 var expires = '';
99 if (days) {
100 var date = new Date();
101 date.setTime(date.getTime() + (days*24*60*60*1000));
102 var expires = '; expires=' + date.toGMTString();
103 }
104 document.cookie = name + '=' + value + expires + '; path=/';
105}
23_createCookie: function _createCookie(name, value, days, path) {
24 var expires = "";
25 if (days) {
26 var date = new Date();
27 date.setTime(date.getTime() + 1e3 * (60 * (60 * (24 * days))));
28 expires = "; expires=" + date.toUTCString();
29 }
30 document.cookie = name + "=" + value + expires + "; path=" + path;
31},
7function createCookie(name,value,days) {
8 var date,
9 expires;
10
11 if (days) {
12 date = new Date();
13 date.setTime(date.getTime()+(days*24*60*60*1000));
14 expires = "; expires="+date.toGMTString();
15 } else {
16 expires = "";
17 }
18 document.cookie = name+"="+escape(value)+expires+"; path=/;";
19}

Related snippets