ASP Session Object

|  | Search W3Schools : |

HOME | HTML | CSS | XML | JAVASCRIPT | ASP | PHP | SQL | MORE... |  | References | Examples | Forum | About

ADVERTISEMENTS XML Certification Download XML editor Custom Programming |  |

Table of contents

ASP Tutorial
ASP HOME
ASP Introduction
ASP Install
ASP Syntax
ASP Variables
ASP Procedures
ASP Forms
ASP Cookies
ASP Session
ASP Application
ASP #include
ASP Global.asa
ASP Send e-mail
ASP Objects
ASP Response
ASP Request
ASP Application
ASP Session
ASP Server
ASP Error
ASP FileSystem
ASP TextStream
ASP Drive
ASP File
ASP Folder
ASP Dictionary
ASP ADO
ASP Components
ASP AdRotator
ASP BrowserCap
ASP Content Linking
ASP Content Rotator
ASP Quick Ref
ASP Summary
Examples/Quiz
ASP Examples
ASP Quiz
ASP Exam

Selected Reading

Web Statistics
Web Glossary
Web Hosting
Web Quality
W3Schools Tutorials
W3Schools Forum
Helping W3Schools

# ASP Session Object

The Session object is used to store information about, or change settings for a user session. Variables stored in the Session object hold information about one single user, and are available to all pages in one application.

## Examples

Set and return the LCID
This example demonstrates the "LCID" property. This property sets or returns an integer that specifies a location or region. Contents like date, time, and currency will be displayed according to that location or region.

Return the SessionID
This example demonstrates the "SessionID" property. This property returns a unique id for each user. The id is generated by the server.

A session's timeout
This example demonstrates the "Timeout" property. This example sets and returns the timeout (in minutes) for the session.

## Session Object

When you are working with an application, you open it, do some changes and then you close it. This is much like a Session. The computer knows who you are. It knows when you start the application and when you end. But on the internet there is one problem: the web server does not know who you are and what you do because the HTTP address doesn't maintain state.

ASP solves this problem by creating a unique cookie for each user. The cookie is sent to the client and it contains information that identifies the user. This interface is called the Session object.

The Session object is used to store information about, or change settings for a user session. Variables stored in the Session object hold information about one single user, and are available to all pages in one application. Common information stored in session variables are name, id, and preferences. The server creates a new Session object for each new user, and destroys the Session object when the session expires.

The Session object's collections, properties, methods, and events are described below:

### Collections

Collection | Description
--- | ---
Contents | Contains all the items appended to the session through a script command
StaticObjects | Contains all the objects appended to the session with the HTML <object> tag

### Properties

Property | Description
--- | ---
CodePage | Specifies the character set that will be used when displaying dynamic content
LCID | Sets or returns an integer that specifies a location or region. Contents like date, time, and currency will be displayed according to that location or region
SessionID | Returns a unique id for each user. The unique id is generated by the server
Timeout | Sets or returns the timeout period (in minutes) for the Session object in this application

### Methods

Method | Description
--- | ---
Abandon | Destroys a user session
Contents.Remove | Deletes an item from the Contents collection
Contents.RemoveAll() | Deletes all items from the Contents collection

### Events

Event | Description
--- | ---
Session_OnEnd | Occurs when a session ends
Session_OnStart | Occurs when a session starts

## Learn how your website performs under various load conditions

WAPT is a load, stress and performance testing tool for websites and web-based applications. In contrast to "800-pound gorilla" load testing tools, it is designed to minimize the learning curve and give you an ability to create a heavy load from a regular workstation. WAPT is able to generate up to 3000 simultaneously acting virtual users using standard hardware configuration. Virtual users in each profile are fully customizable. Basic and NTLM authentication methods are supported. Graphs and reports are shown in real-time at different levels of detail, thus helping to manage the testing process.

Download the free 30-day trial!

WEB HOSTING
Ecommerce Components for ASP.NET
$15 Domain Name Registration Save $20 / year!
Buy UK Domain Names Register Domain Names
Cheap Domain Names Cheap Web Hosting
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE Web Hosting

WEB BUILDING
Website Templates Flash Templates Website Builder Internet Business Opportunity
Custom Programming
FREE Trial or Demo Web Content Manager Forms,Web Alerts,RSS
Download XML editor
FREE Flash Website
FREE Web Templates

EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification

HOME or Top of Page |  | Printer Friendly
W3Schools is for training only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy. Copyright 1999-2009 by Refsnes Data. All Rights Reserved.