Very basic Seesion Variables question

R

Ray

Can somebody please tell this. If I put this statement <% Session("User") =
("Fred") %> somewhere into my code on one page, can I then, from another
page, enter this code <p>Welcome <% Session.Contents("User") %></p>, should
I get the message "Welcome Fred"?
Because I don't and I don't know why. This is s new subject to me so please
be patient! Obviously Fred is a literal. not a variable, but I would like
eventually to read that value from a table, but first things first.

Ray
 
R

Ray

As I have said, I am a beginner in all of this. So is this statement wrong:
<% Session("User") = ("Fred") %> ?
 
M

Mark Fitzpatrick

No, the statement is correct, but sometimes the Session variables don't work
well when set on the same page and then trying to access the updated value.
Typically, they're for sharing variables across multiple pages so if you set
the Session variable in one page, you "should" be able to get at it from
another. I say should because Session variables seem templermental
sometimes.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
T

Thomas A. Rowe

First, all of your pages must be .asp within your site, or the session will suspend as the user move
between pages. Also session do not cross subweb or domains.

1. Define the session, as in:

<%
Session("User") = "Fred"
%>

2. To display:

Welcome <%=Session("User")%>

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
R

Ray

Mark,
Thanks, but as my original post says, they are on different pages. I just
really want clarification that what I have done is right, and if not, how I
should code it correctly.
To re-iterate, all I want to do is set up a session variable on one page,
and read it in another. Once I've got started I can hopefully work the rest
out for myself.
But thanks for taking the time to reply.

Ray
 
Top