 |
| ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 2nd, 2003, 09:11 AM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Session variables for multiple users
I have a ASP script that sets up a variable Session("uid") = uid (for a valid user) .
Problem is when I try for multiple users Session("uid") takes up value for current user and loses information about old user.
How do i assign session variables for multiple concurrent users.
|
|

October 2nd, 2003, 09:22 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
This is not the way it should be. Session variables are tied to one single user, or Session.
If they are overwritten, you may not have created an entirely new Session. When you open a second browser instance, using Ctrl+N for example, both browser windows share the same Session (because the two windows share the same cookie collection, where the ASP SessionID is stored).
If you open a new browser window from the start menu, or running YourBrowser.exe, you should get two unique Sessions on the server, and each Session should be able to store its own unique user ID.
If this does not solve it, please post some code as you may have a problem in your implementation.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

October 2nd, 2003, 11:06 AM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks for your help. I am pretty new to sessions. How do i make sure every time a new user logs on, a new session is created. Do i have to write it in the global.asa file under Session On start()
Please help.
|
|

October 2nd, 2003, 12:53 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Nope, this will be done automatically by the ASP runtime, provided you have Sessions enabled on the web server.
When a user requests one of your pages, the ASP run-time hands out a cookie with the Session ID. This cookie will remain valid as long as the browser window is open, and is never stored to disk to last between browser sessions. So, every time a new browser instance is opened, you'll get a new cookie with a new session ID and thus a new session.
The reason this may not be working for you, is that you're not really opening a new instance of your browser, but by spawning a new window from one of your other browser windows. A browser window you open from another browser window (File | New | Window, Ctrl+N, or through JavaScript) will all share the same Session cookie and thus share the same Session on the server.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

October 7th, 2004, 09:43 PM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi, I have a very wiered problem on session handling, I hope someone could help me on this. As we all know, pressing a Ctrl+N would open a new window and also both browser would have the same session. But in my case a particular page of mine(other pages are working fine in this situation), if I would press Ctrl+N, I would get a new session id on the newly opened new window. Does the session has a limitation on data stored in it and thus the ASP would give another session for my newly opened window?
Please help me on this... Thanks a million for your time and inputs...
|
|

October 8th, 2004, 01:58 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
This is very strange. How did you check this? Did you create a simple page that writes out the Session ID when it is loaded? If not, can you create such a page and test it out?
And what happens when you store a value in the session and write it out in a later page?
One thing that can cause a new Session ID is a browser that doesn't support cookies, or software that blocks your cookies. However, in such a scenario, each page should get a new Session ID.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

October 8th, 2004, 10:01 PM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi, thanks for your reply. I'm sorry if this is somewhat out of the thread. I'm actually using ASP.Net, the flow is the user would login to the login page then I store the UserID in the session. Then I noticed in this particular page everytime i would press Ctrl+N, I would be redirected back to the Login page (I put a code if UserID in the Session is empty, I would redirect it to Login page). When I investigated i noticed that the newly opened page has a different session id than the current page and thus has an empty UserID. I was wondering because I store a DataSet (more likely the same as Recordset in ASP) in the Session and in this particular page, a large DataSet is stored, would it be that the session has a limitation? I look at the event log there's nothing written in there and ASP_Net process doesn't recycle (it still consume a large amount of memory). Where does the Session stored, is it stored in the Client Side or in the Server Side? Hope could you help me on this.
Thank a million in advance...
|
|

October 9th, 2004, 08:47 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
The session is stored in the server. That's the whole idea about sessions: allowing you to store user specific data at the server at then reconnect that data to a user on each request.
Data can be stored in the process of IIS, a separate state server or in SQL Server. This depends on the settings in your Web.Config file.
Like I said earlier, did you create a simple test page to test this out? There is not much point in trying to figure out if the dataset is the problem, when it appears that the page doesn't even work in a simple scenario.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

October 10th, 2004, 08:46 PM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi, thanks for your reply. I changed my session state already to StateServer. And so far there's no problem now(this particular page class already works). I didn't place any code to display the session id to the page, I noticed it during debugging. But it is a little bit slower than before.
Thanks a lot...
|
|

November 15th, 2004, 03:49 PM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I've run into a similar issue. I have an ASP.Net application that retrieves and sets specific client based info into session variables. Everything is fine until a user spawns a new window using Ctrl+N. Because the session Id is the same, the session variables get confused between the two windows. Even more distressing is when they have a session open for one client and then receive an email with a link to a second client. The new window opened from the email has the same session id as the original, different client window, again causing problems with mismatched session information.
Is there a way to force a new session id (target _blank didn't do it) when appropriate?
Thank you,
Angie
|
|
 |