Wrox Programmer Forums
|
ASP E-commerce As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP E-commerce 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
 
Old December 9th, 2003, 04:48 AM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple sessions for the same user

Is it possible to start 2 sessions for the same user.
Say, the state of a transaction is being maintained using session variables. So how can we allow user to make 2 distinct transactions simultaneously(which would require 2 distinct sets of session variables).
 
Old December 9th, 2003, 01:32 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I don't think that will work. ASP uses a cookie to track the Sesision ID. The name of the cookie is always the same, so it will overwrite any previous cookie when you assign a new one.

When you lost the cookie with the SessionID, there is no way to hook up the user Session back to the Session on the server again.

One thing that *might* work is the Cookie Munger, available in the IIS Resource Kit. This application uses QueryStrings instead of cookies, so you may be able to use pages with a different ID in the QueryString. Please note that the Cookie Munger is not really recommended (not even sure if it's still available). It's pretty, and a bit tricky to use and configure.

Why do you need to sessions to maintain state of a transaction? What kind of transaction are you talking about? Not database transactions, I hope?

Regards,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old December 11th, 2003, 05:04 AM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the tranactions are not database transactions
its similar to say if user goes to a ecom site, he can pick up some goods from their electronics store & some from their bookshop.

what i wanted is that these transactions, carried simultaneously, should have their distict state maintained. the user could do muliple transaction at the time (around <=5) and also the user traffic wont be much (max 15 users are allowed).
so what i came up with is that, for a particular user i would generate multiple 'session variables' at runtime (for each transaction started by user i would generate a variable name var1, var2 etc to hold the state of the user)

here i wanted to know: if i'am storing reference to a component(the component would store the data related to the transaction as its public properties) in the individual session variables. then would these session variables consume too much memory because of the data stored in the component instance OR would the session variable only hold the 'reference' to the component instance and hence is light on resource consumption.

also would multiple session variables (max = 15*5) at any time, affect adversely the performance of iis?

 
Old December 11th, 2003, 05:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

If you do use sessions, why not keep a simple Transaction counter / tracker.

For example:

Session("TransCounter") = Session("TransCounter") + 1
Session("CurrentTrans") = 3

This code would increase the transaction counter, and then set the active counter to 3 (just an example).

In other ASP code, you can retrieve info about the current transaction like this:

Dim TransactionName
TransactionName = Session("TransactionName" + Session("CurrentTrans"))

This code will retrieve a dynamic session variable. That is, in the example above, it will request Session("TransactionName3") which will return the name of the current transaction, number 3 in this case.

Personally, I am not too happy with storing objects in memory. Usually, I just store a unique ID in a session (or aa cookie) and then use that ID to store and retrieve information from a database. This makes it easier to scale your app, if necessary.


It depends on how large the object is that you're storing in memory. Ordinary text variables shouldn't have a large impact on performance; however, storing large objects like Recordsets (don't do that) in memory can severely hinder the performance. Even if the session just holds a pointer to the object, the object itself is still consuming memory.....

Cheers,

Imar



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 14th, 2005, 11:56 AM
Registered User
 
Join Date: Jul 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

With Internet Explorer, if you use Contrl-N to open a new window, that window will use the same session cookies as the first one. But if you load a new instance of IE from the start menu and then browse to your Web site, that instance will have a new session that's independent of the first one. Both sessions can be maintained.

Firefox, however, shares the same session cookies across all instances of the browser, so whatever you do in one window can affect will happens in all others.

Session cookies are not persistent (not saved the hard drive). The cookie name is created at random and looks like a GUID.

Jim
 
Old February 15th, 2005, 03:04 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Interesting; I didn't know Firefox shared cookies among all browser instances.....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use sessions to remember logged on user? MTLedari ASP.NET 2.0 Basics 6 December 7th, 2006 04:17 AM
Cookie usage with multiple sessions DarrenMelling Classic ASP Basics 7 August 14th, 2005 07:11 PM
Creating Multiple Sessions sen_d007 Classic ASP Basics 4 September 22nd, 2004 07:00 PM
Sessions - one user has problems kc5f Beginning PHP 7 June 8th, 2004 07:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.