|Home | Get UltraDev | UltraDevExtensions.com | Dreamweaverfever.com | Macromedia | Useful Links |

Remember Me

It's about Cookies, isn't it?

Some years ago I had a great summer job in Maryland, USA driving an ice cream truck for Good Humor Corporation. Didn't sell much ice cream 'cos I ate most of it! Today we'll be working with cookies. Yum yum ...

As you probably guessed, this lesson is about remembering the visitor when she next visits your site so that her username and password are already filled in on the Login form.

To do this we're going to make a small addition to our New User Registration form to allow our user to choose whether she wants to be remembered, and a small amendment to the Login page to show her that we did remember. We shall do this by writing two cookies to her PC - it's dead simple as you'll see. But first try the demo.

Steps

1 Add a checkbox to the New User Registration form
2 A little code to write the cookies
3 Amend the Login form a little

1 Add a checkbox to the New User Registration form

Add a checkbox to the login form labeled 'Remember Me' as you saw in the demo. I named this checkbox cbxRemember. Notice in the properties tab that the default selected value inserted by UltraDev is 'checkbox'. You can change this to True or Yes or whatever else you prefer (how about Oui?). You will use this in the next step.

2 A little code to write the cookies

Press F10 to open the HTML source window. Somewhere at the top of your code you should have the code for stuffing the UserID into a session variable. We added that in Lesson 4 remember? Immediately below that we will put the code to create the two cookies ckUserID and ckPassword.

We put this code at the top of the page for the same reason described in Step 1 of Lesson 4.

We want the code within the If ... End if to run only when the checkbox has been checked. If you had something other than "checkbox" as your selected value (Oui?) you should amend accordingly.

The 90 means your visitors will be remembered for 90 days. That's longer than anyone has ever remembered me :)

(Wow Hiran ... is that all the code we're going to write today?)

3 Amend the Login form a little

Now to make the visitor's userID and password get pre-entered on the Login form - take a look at the Initial Values of the UserID and Password boxes of the Login form on your Login page. I just typed this in, but you can use the data binding tab to insert this also.

Well, nothing much can go wrong in this example. (Go on, prove me wrong!)

Ok, that's your simple introduction to using cookies.
Delicious, huh?

 

BTW Getting back to the ice cream Hello to Cathy Parr, Vicky Rice and CJ from Montgomery Village, Gaithursburg, MD - got a whole truck load of Italian Ices here :)

Home | Write a Review | Read Reviews | Email Hiran