/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] JavaScript Cookies!

Hello everyone! ?

I am having [COLOR=”Red”]really tough time[/COLOR] learning [COLOR=”Red”][B]JavaScript Cookies[/B][/COLOR]!

Can somebody explain me how to use them?

“Please [COLOR=”Red”]do not provide any external links[/COLOR]! It is a request!”

Any type of basic[COLOR=”DarkOrange”] lesson/advice/suggestion[/COLOR] will be quite helpful to me.

[I]Thanks![/I]

?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@wbportFeb 27.2012 — These functions should get you started:
[CODE]function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}[/CODE]


The above is from a page used to create guitar chords. The user can choose a number of options and these will be the default when the user gets back within the next three months.
Copy linkTweet thisAlerts:
@TheAliveWinnerauthorFeb 27.2012 — These functions should get you started:
[CODE]function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}[/CODE]


The above is from a page used to create guitar chords. The user can choose a number of options and these will be the default when the user gets back within the next three months.[/QUOTE]


[B][SIZE="3"][FONT="Century Gothic"][COLOR="Green"]Thanks a lot![/COLOR][/FONT][/SIZE][/B]

[I][COLOR="DarkRed"][FONT="Verdana"]Actually I was getting the tutorial at lots of places, but what I was actually not able to understand was how to call them or initialize them!

But the link provided by you proved to be greatly helpful!

Thanks again![/FONT][/COLOR]
[/I]
? :p
×

Success!

Help @TheAliveWinner spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...