/    Sign up×
Community /Pin to ProfileBookmark

i’m a newbie to cookies. trying to create a cookie when user has successfully submitted email (i.e. [email][email protected][/email] vs just joe). when user revisits i can determine which page to display, registration or login page, depending if the cookie is present or not.

is that difficult?

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@justinbarneskinFeb 26.2009 — Not hard at all. You only need your basic cookie script and refer to it in a script tag.

Once you find you do-all to end-all your cookie needs, you can use it over and over again on different pages for different forms. Just need to name each cookie unique.
Copy linkTweet thisAlerts:
@budsterFeb 26.2009 — An example basic cookie script

http://www.astral-consultancy.co.uk/cgi-bin/hunbug/doco.cgi?11180

Hope this helps
Copy linkTweet thisAlerts:
@chappieauthorFeb 27.2009 — not sure where and when to call setCookie(...)?

btnConfirm_Click()

if (valid email)

setCookie (name, ...)
Copy linkTweet thisAlerts:
@chappieauthorFeb 27.2009 — didnt read down far enough. i see when to call in the example. another question(s):

//call testCookie on submit

function testCookie()

{

//where's txt input String written in this line?

setCookie('cookietest',document.getElementById("t1").value,1);

//is this testing if cookie present or not?
alert(getCookie('cookietest'));
}



//what does this do?

<script type="text/javascript">

document.getElementById("t1").value = getCookie('cookietest');

</script>
Copy linkTweet thisAlerts:
@budsterFeb 27.2009 — Hi Chappie

When you run the cookie example you get a text input and a submit button.
//where's txt input String written in this line?

setCookie('cookietest',document.getElementById("t1").value,1);
[/QUOTE]

"document.getElementById("t1").value" gets the string value entered from the text input box. Enter whatever text you want to place in the cookie here.
//is this testing if cookie present or not?

alert(getCookie('cookietest'));
[/QUOTE]
Yes, the value displayed in the alert is coming from the cookie
//what does this do?

<script type="text/javascript">

document.getElementById("t1").value = getCookie('cookietest');

</script>
[/QUOTE]
If the cookie exists when the page is loaded, it will set the input text box value to that of the cookie value.

Hope this helps
Copy linkTweet thisAlerts:
@chappieauthorFeb 28.2009 — budster,

thx for the info. i'm able to create and store a cookie now?

however, i need to validate email before i create cookie. i found a script to do this.

the script calls validateForm( ) which calls validateEmail() so i should call setCookie( ) in validateForm ( ) after validateEmail( ) returns. does that sounds right?
Copy linkTweet thisAlerts:
@chappieauthorFeb 28.2009 — budster,

is my logic reversed in the above post...should i call testCookie( ) upon submit and then call validateForm( ) in testCookie( )? or does it matter?
×

Success!

Help @chappie 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...