Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 11th, 2003, 02:08 PM
Authorized User
Join Date: Jun 2003
Posts: 10
Thanks: 0
Thanked 1 Time in 1 Post
Default Passing Session Variable

Hi Everyone,

   I am new to using session variable in ASP. I would like to know how to define a session variable from a user login password, then pass that session variable to all protected pages and using the session variable to query the data in a table. Any suggestion is very appreciated.


Old December 11th, 2003, 03:44 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

On the page that processes your login, you just need to set the session variable to the desired value. The format is Session("<key string>") = <value>

Session("sUserPassword") = sPassword

Then on the pages that need to use it, you just call it like this:

sPassword = Session("sUserPassword")

If the value doesnt exist (i.e., your user hasn't logged in) the value will be blank.

sPassword = Session("sUserPassword")
If sPassword <> "" Then
    'Do what you need for a logged in user
    'Handle non logged in user.
End If

Work smarter, not harder.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing a Session Variable in a href orcabelle ASP.NET 2.0 Basics 3 May 21st, 2007 03:41 PM
Passing a Variable LarryS Beginning PHP 1 August 8th, 2006 07:52 AM
Passing variable to a public variable Hudson40 Access VBA 2 February 25th, 2005 06:23 AM
Passing a variable mrideout BOOK: Beginning ASP.NET 1.0 3 August 6th, 2004 02:57 PM
Passing a variable trekmp ADO.NET 1 March 4th, 2004 01:57 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.