logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
Action Movies
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel
Southwest USA


dailyclick
All times in EST

Clairvoyance: 08:00 PM

Full Schedule
g
g ASP Site

BellaOnline's ASP Editor

g

ASP Session Object Variables


Usually when you code an ASP script, the variables you use only exist while the script runs. But what if you want to code a shopping cart, or something else where data is kept active?

You could start storing all the data in a database, but this takes up space and uses time. It's much easier to work with the session variable space. By default, this space stays active for a given user for 20 minutes.

The session begins as soon as a given computer has a session value stored for them. This creates a cookie for that computer, logging the date and time of entry. From that point forward, every new session value change they do updates the 20 minute timer. If you want to change the timeout value, use:

Session.Timeout=10

or whatever minute number you want to use. Remember, session values take up memory. So you want this to be long enough that the user can get through their task, but short enough that you do not have many different sessions open without reason.

To use a session variable, simply put data into it. If a user enters their age and you want to track this for as long as the user is using your pages (to keep them away from mature material, for example) you would use:

Session("age") = 25

to assign it, and then

if Session("age") >= 21 ...

to work with it. Typical uses for the session variable are an age, a log-in user ID and password, shopping items in a shopping cart, and flash vs html user preferences.

If you're done with a given session and want to end it early, perhaps because the user chose a "log off" option on your site, you would use

Session.Abandon

to completely end that session's run.

Introduction to ASP Ebook

Download this ebook to get everything you need to know about learning ASP - from a step by step tutorial to function lists, sample code, common errors and solutions, and much more! 101 pages.
Add ASP+Session+Object+Variables to Twitter Add ASP+Session+Object+Variables to Facebook Add ASP+Session+Object+Variables to MySpace Add ASP+Session+Object+Variables to Del.icio.us Digg ASP+Session+Object+Variables Add ASP+Session+Object+Variables to Yahoo My Web Add ASP+Session+Object+Variables to Google Bookmarks Add ASP+Session+Object+Variables to Stumbleupon Add ASP+Session+Object+Variables to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2014 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact Lisa Shea for details.

g


g features
Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor