Do you want to remember your members?
By this I mean, on your login form, have you ever wanted to have a “Remember me” checkbox, allowing the member to not have to enter their username and password every time the come to your web site?
The trick to this is using ColdFusion Cookies! No, Not chocolate chip cookie, ColdFusion cookie! (They taste even better then they sound! Let me show you an example:
First let me explain what cookies are, cookie are files that are stored in your browser to allow you to put and get information for later us (Think of your browser cookie area as a cookie jar and all the cookies you get online are different types of cookies. Now, defining and using a cookie in ColdFusion is actually quite simple. Let me show you how you define a cookie and how you read a cookie.
To define a cookie, you do this:
To read a cookie, you do this:
Now, cookies have a lot of settings you can use, but in this example we’ll take it one step further, you will be using the “Expire” variable setting. This will allow you to tell the cookie when it expires and is no longer usable. In this tutorial we will set that value to NEVER, because we never want the cookie to expire (We want it to ALWAYS be accessible).
The first thing we must do it to create the login.cfm page, this will be the form that users will enter their username/password to log into the site.
The first thing we need to do is to see if the cookies exist, to achieve this we will use:
Next let’s see if the password exists in the cookies (It’s suggested that you dont save the password, but some of you MIGHT want that feature, so Im implementing the code either way
The next thing we need is the page “login_process.cfm” this is where the magic takes place, not only do you actually authenticate your users to verify their members, but you also remember or forget their login information. Let’s see the code:
That’s pretty much it, you can now give your users the “ability” to not have to enter their login details everytime!
EasyCFM.Com introduces at least three new tutorials each week, written by the webmaster (Pablo Varando) and also from individual people who post their own tutorials for visitors to learn from. For more information please visit: http://www.easycfm.com [EasyCFM is Hosted by Colony One On-Line – http://www.colony1.net]