Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

session variables

Status
Not open for further replies.

jkl

Programmer
May 16, 2001
83
US
Are session variables that are set in one application, available to another application, running on the same website?
 
umm... NO
The second application has an entirely different set of session variables because uh huh you may have guessed. It is a second session! That'l do donkey, that'l do
[bravo] Mark
 
JKL:

If you did have information that you wanted to share between apps, you could set up a structure with whatever database you're using, assuming that both applications would have access to it.

i.e. You could set up a Shared SQL Server database, which App1 and App2 both have access to.

Of course, if you're thinking more of a "I have one webpage, and I want the second webpage to use the same variables", then you're looking at passing the values through the querystring, and assigning those values to session vars in the new app on arrival (query string info isn't the most secure way to send info, so thats a consideration too)

jack
 
so even if i use the asp stateserver method, i cannot share session variables?

I have one application that does user registration and login. I have another application running that serves up customized pages based on the user's UserID. I want to be able to pass the UserID to every page on the site using session variables. Is this impossible?
 
Do they have to be seperate applications? Why not just combine them into one app with different components:
- a login component
- a content generation component

Then you could keep the userid in session.

jack
 
They're separate applications because different people have ownership of each module on the site. I suggested creating them as different components to the same application, but the Manager disagrees. So there are no server wide session variables like there used to be with standard ASP?
 
I'd love to have words with your manager. you might want to let him know that managing who gets to see what pages (i.e. what my company is doing with a large member portal) isn't that hard to pull off, and is actually made harder by having multiple apps for one page.

Regardless, no, to my knowledge there aren't server-wide session variables. The session variables only survive the current session. Now, with that said though, you should test that theory out and try to access a session variable accross the application pages just to make sure. But to my knowledge, since they're in seperate virtual directors in IIS, no, they can't be shared.

Jack
 
But you could go the database route. All applications would have access to a database table that was in charge of maintaining state across many apps on the same server.

You could even plug in the sessionID to the table(s) if that info is important at all.

:)
paul
penny1.gif
penny1.gif
 
is i go the sql server route, how does a visitor share his info from one app to the other?? how do i identify him as user xyz, from application "Registration" as user xyz within application "Customized Center".

I also need to ne able to share the user's ID within several dozen standard ASP pages that are currently on the site.

Basically, we have dozens of articles on our site, that are .ASP pages. We want to give the user the ability to "save" the article into their "My Articles" section.

Also, when I mentioned "ownership", I meant it in terms of development. I'm developing the "My ..." stuff and another developer is doing the "registration/login" and another ..., and so on and so on.
 
Well, I assume each user has their own ID, yes? If so, then you'd just use that to identify the field in the database as belonging to that user. If you don't, then you'll need to create one. I don't see any other way to do it.

This will also meld quite nicely with your need for existing asp pages to use this information, too, which would not be an option with asp.net session state.
penny1.gif
penny1.gif
 
still confused. yes each user has a unique ID, but how does the server know which session/visitor belongs to which ID? How does it associate a certain surfer with that ID? There's got to be some kind of correllation in retrieving the visitor's ID from the sql database while they are surfing.
 
Ok, I log in as user1. my id is 123.

Once I login, you use a classic session variable to hold:

session("userID") = 123

Then, I view article1, and tell you I'd like to save it. At that point, you make an entry into table, tblArticles, and it would looke like this:

userID | articleID
--------------------
123 | 1

Unless I'm missing your point completely, that should wholely solve the problem. At that point, if I go and log back into another application, then my userID is still 123, right? So you go grab:

SELECT articleID FROM tblArticles WHERE userID = 123;

And typically, I'll have a nice handful of them in there.

If you're trying to uniquely identify a user w/o the use of a customized id, i.e. one that I would sign up for, then I don't see how you could do that. The only way would be like I've described.

Am I missing something, or is that what you need?

:)
paul
penny1.gif
penny1.gif
 
paul,

i don't think i'm explaining this correctly.

i can work out the entire userID --> articleID relationships just fine in the tables. what i'm having trouble with is tracking userID across pages.

i.e.

- new visitor
[no userID]

- logs into "login app; .NET"
[session("userID")=123]

- random surfing on the site
[session("userID")=123]

- viewing articleXYZ.asp
[session("userID") no longer available, it's an ASP page, not ASPX]

- go to "My Articles app; .NET"
[session("userID") is empty because it is a separate application from 'login' which first supplied the value for session("userID")]

how do i get the session("userID") value to persist across two different .NET applications, 'login' and 'myArticles'; as well as the currently existing ASP pages?
 
querystring is the simplest way to accomplish that, so that the asp.net link to get to the article would look like this:

articles/getArticle.asp?articleID=xyz&userID=123

and vice versa to get back to the asp.net page(s) --

articles/findArticles.aspx?userID=123

That's how I'm integrating my personal web beast with asp.net. It can get quite messy getting them to play nice.

There isn't a magic pill to make it easy. :-(
penny1.gif
penny1.gif
 
Paul,

I was afraid of this. I know that query string would solve a lot of these issues, however, the problem with that is, there are over 100 articles, each is a separate .ASP page, with 3 times as many links to these articles.

The logictics of passing the userID from one page to the other, across multiple .NET applications and hundreds of other .ASP pages is prohibitive of this method.

I wish I could scrap the entire site, and start from scratch. Tell me boss "Hey boss, gonna shut down the website. Re-write everything into one .NET application and roll it back out in... 6 - 8 months. Okay?"

Ugh!

But thanks for all your help so far.
 
K, then a shared database is the way to go. What database are you using: SQL Server, Oracle, etc?

Jack
 
we use sql here.

but i think i've found a way around it. gonna use cookies. that's the only way i've found to pass userid across to all pages.

those users who don't ahve cookies enabled, don't get to have customized pages.
 
HAH! If YOUR users are anything like MY users, THAT won't fly!

Your best bet would really be to use the database idea, since that would mean that everybody would get the customized versions.

In a perfect world, everyone would be geeky like us. Mind you, I guess that would mean we'd be out of jobs...and besides, someone has to look over the little people
;)

*phone call our office recieved this morning from a client:
"Yeah, um, it says to enter a password, but I looked through the manual that came with the computer and there's no password"
/me shakes his head

jack
 
how does the database method work when there's no common identifier that follows the user from application to application across the entire website?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top