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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One session on two sites

Status
Not open for further replies.

achmo

Programmer
Aug 30, 2001
56
IL
Hi,

I have two sites on the same machine (one directly under the and one defined as a virtual directory). I am using IIS on a windows NT server.
I want the users to be identified by the same session, so after he entered one site (successfuly typing username and password) and I save a session for him, I could use the same session to identify him if he goes to the second site (so he wont have to retype his username and password).

For now, when I click a link I created from the first site to the second, it seems the session is not recognized (it is empty).

Are two seperate sessions created for two sites? Is there a way to work with one session?

Thank you for your time

Yael
 
Without knowing the exact layout of how you're two different sites are setup in IIS, I will just say that you cannot access session variables from one web site to the next.

Are you using a database for you application ?? You could easily persist Session Variables from site 1 to site 2 using a small table in your database and the Request.ServerVariables("HTTP_COOKIE") method.

Basically, you could place the Request.ServerVariables("HTTP_COOKIE") string, with a key identifier, in the url that is accessing site #2. Then when the user clicks on the link for site 2, direct them first to an ASP page that writes all of the session variables to a table with the Request.ServerVariables("HTTP_COOKIE") in an ID field for each record. Then redirect to site 2 with that Request.ServerVariables("HTTP_COOKIE") still in the url. On site #2, use the Request.QueryString method to read the SessionID from the url, and request those records in the table that match that ID and write those key/value pairs to the new session created in site #2. Back on site #1, place a DELETE statement in your on session end portion of your global.asa file that will delete those records when the session ends on site #1.

Is that making any sense. I was going to suggest writing a cookie file to the browser before navigating to site #2, but something tells me that you might run into problems there. (Again, not knowing exactly how you have setup the two sites.) Cookies should work, and would be a little easier (depending on the amount of data you want to persist) if both sites are part of the same host IP. But the database table solution is sure fire !!

Let me know if you have any questions.

ToddWW
 
Hi,

First, thanks for taking the time to think and help. I really apreciate it :)

After reading your answer, I had an idea - why not simplify your suggestion, and just pass the variables I need on the link's url to the middle page (which will be part of site #2), and there use REQUEST to save them to a new session on the 2# site?

Just as you suggested, but without using a database! (I have only three or so variables to pass, so there is no length problem on the url)

It seems to me this should work. What do you think?

Yael
 
ok, the simple version works :)

Yael
 
Yes, I was going to suggest passing all of the variables through the URL, but just remember that it's not scalable. In that you can only send 256 characters in the URL including the page address.

As long as you know that you're going to stay under that, you should be fine.

ToddWW :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top