Session variables with FP2003

R

Ray

I don't know much about these yet, but I want to be able
to pass certain variables to all of my asp pages. What I
want to do is read all of the variables from the database
on my default.asp page and then then when I navigate
around the site be able to pass them around without having
to re-read them each time.

I've heard about seesion variables - would these do the
job, and if so how do I load them and subsequently use
them.

Ray
 
O

odyssey

the answer is yes. I cannot answer all of you questions right off but email
me, I will tell you more. and hopefully be able to translate it to a post
for here to all..

[email protected]
 
M

MD Websunlimited

Hi Ray,

To set a session var use
session("var_name") = value

To use a session var use
var value = session("var_name")
 
O

odyssey

HI! ray, first your most use the extension .asp and then you can put some in
your global.asa page.

Here is an example plan example of one of my global.asa files. and notice
towards the bottom as I put a small command to abandon the session on End.

---------------------------------------------Example------------------------
-------------------

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

'You can add special event handlers in this file that will get run
automatically when
'special Active Server Pages events occur. To create these handlers, just
create a
'subroutine with a name from the list below that corresponds to the event
you want to
'use. For example, to create an event handler for Session_OnStart, you would
put the
'following code into this file (without the comments):

'Sub Session_OnStart
'**Put your code here **
'End Sub

'EventName Description
'Session_OnStart Runs the first time a user runs any page in your
application
'Session_OnEnd Runs when a user's session times out or quits your
application
'Application_OnStart Runs once when the first page of your application is
run for the first time by any user
'Application_OnEnd Runs once when the web server shuts down
Sub Session_OnEnd
Session.Abandon
Sub Session_OnStart
Session("CameFrom")=Request.ServerVariables("HTTP_REFERER")
End Sub
End Sub
</SCRIPT>
---------------------------------------End of
Example-----------------------------------

Here is another example of how to use a session var. this is the first line
in the page.

session("image")="/images/mainlogo.gif" ( I am not sure about the quotes
around the images/mainlogo.gif, just remove then if it does not work.)


-----This will request the session var once you have set it in your start
page for example.
<%
Session("image")=Request("image")
%>
----------------------------------------------------------------------------
------

------Now here is how you can use it.
<head>
<meta NAME="GENERATOR" Content="Microsoft FrontPage 7.0">
<title>Your Website</title>
</head>

<body background="<%=Session("image")%>"
----------------------------------------------------------------------------
-----

You can also put multiple variables declarations in a .js file ( you can
even create it in notepad - just simple text file.)
----Here's how to initiate them. ( put it in the head section.)

<head>
<title>Your Website</title>
<Script Language="JavaScript" src="../jsfiles/mainvars.js"></Script>
</head>
----------------------------------------------------------------------------
-----

I hope this helps answer a few of your questions. :)

Paul Dallaire--Odyssey

[email protected]
 
Top