Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: Scope of variables

$
0
0
Re: Scope of variables
Web Connection
Re: Scope of variables
04/23/2012
06:33:31 AM
3HI0E272I Show this entire thread in new window
Gratar Image based on email address
From:
Potter Orr
To:
Attachments:
None
Rick,

The more I read your answers the less I think I know. What and where are "declaration of properties for the page" ?

Do the sample WestWind projects (TimeTrakker etc.) use Session? Maybe if I could see the use in action it would make more sense to me.

Potter


You can also enable session state for individual Page classes by setting

EnableSessionState = .T.

in the declaration of properties for the page. This too fires InitSession() if it hasn't been fired yet.

Along the same lines:

Process.lEnableSessionState = .T.

can also be used (in pages or any other code) to do effectively the same thing.

+++ Rick ---


Thanks - as always. I understand but still don't know which piece of code should get the function OnProcessInit(). I do not have that function anywhere that I can find.

The way my application is structured, the entry point is a page called userin.alb (.alb is the extension I am using). The user provides a valid email address and password and clicks on a login button to start the process. Only if their information is valid will they be allowed to proceed so I guess this is their entry point. Should the function be in this code and be called by the login button click method?

Potter

You don't have to do anything other than making sure you add:

FUNCTION OnProcessInit() this.InitSession() * .... any other code that needs to happen at start of every request

into your OnProcessInit() function. This gets the session object initialized for all requests and makes the Session object available.

I'm surprised that you've come this far and have not yet had a need to use the Session object...

+++ Rick ---



Ian,

Thanks. I read the help file sections (several times) and it looks like I can create a session, store data using sessionsetvar and retrieve it later with sessiongetvar.

What I could not figure out was where and how I get the wwsession started. Does it have to go in the WestWind program in c:\wconnect\... or in my code behind segments in c:\inetpub\wwwroot\...?

Potter


Potter... the place to keep user 'global' variables and their data is in the Session... look up the wwSession class in the Help file under Framework Support Classes... review the 'How It Works' topic... there is an explanation of how to utuilize this class... basically, the first time a user logs in and throughout the hit you can place 'global' variable/values in their session... then when they return you re-initialize these variable/values to 'maintain' their state for the logged in user... another way to maintain some state is to utilize a 'License Plate' methodology in the URL, though this is more involved... HTH...

I am still/again confused about this stateless nature of the Web application and in particular scope issues. When the user comes to my site, I force him to login with an e-mail address and password, look them up in a FoxPro table and determine what kind of access they should be allowed. How do I create memory variables or an object that will remain in scope in the various code behind programs throughout the users session? If I create a variable in the top-level Web connection executable, I presume it will remain in scope throughout, but will each individual visiting the website have their own set of these top-level variables?









Viewing all articles
Browse latest Browse all 10393

Trending Articles