Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 18th, 2003, 03:42 AM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Article Discussion: Session Replacement in ASP

If you have any questions or comments about this article then please post them here!

Reply With Quote
  #2  
Old June 23rd, 2003, 12:20 PM
tomkelleher tomkelleher is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 3 tomkelleher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Barely, barely scratches the surface of session object replacement...

It was an interesting article, but it's hard to see how I would scale such a solution beyond just the simple two-page site you described. The introduction seemed to promise a technique for replacing the Session object with a database, but it doesn't even come close. Creating a simple ID and tagging it onto the QueryString for a single link is trivial. How would I use this technique on an ASP app where dozens of links appear on each page, all pointing to various other internal pages in my ASP app? I would need some central routine to tag that querystring onto every link! Without that, this would quickly become unmanageable.

Also, the introduction seems to promise the ability to "replace" the Session object. It only shows a way to replace the session ID. What good is that without persisting the *data* that a user might otherwise put into the Session object? Suppose when the user logs in they indicate their first name is "Tom". Rather than do Session("FirstName") = "Tom" I would expect to find some routine to store this in the database, and later retrieve it. But there is none. How exactly have I replaced the Session object then?

- Tom

Reply With Quote
  #3  
Old June 23rd, 2003, 04:02 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 7
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
Thank you for finding my article interesting.

You are right that in order for this to work, you need to tag this querystring to all redirects in your asp application.
However, this is the only key you need to tag. So, instead of storing a lot of data in session objects, you use the database to collect all that information, with this key as the identifier.

I have used this approach successfully on our site. As long as you tag the sessionID to all the redirects, you have a good working solution with this approach which in my mind is better scalable than the session objects especially when you add more servers in a load balanced web farm.
__________________
- Rogier Doekes

Reply With Quote
  #4  
Old June 23rd, 2003, 09:28 PM
tomkelleher tomkelleher is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 3 tomkelleher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Rogier,

It sounds like you have taken this principle much further in real life than this article! Excellent. I'd be interested to hear in later articles how you handled the management of adding the identifier string to all your links. In much of my work, our links are generated dynamically depending on the query the user has performed, and the screen they are looking at.

Also, it would be great to hear how you manage the collection and reinstantiation of the Session data on each page. For instance, do you retrieve just the pieces needed for each page, or pull up the whole lot and let the page use what it needs? Do you store just scalar variables, or do you store arrays, objects, collections and the like?

- Tom

Reply With Quote
  #5  
Old June 24th, 2003, 07:43 AM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 7
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
Hi Tom,

We let the database do most of the work. To give you an example: We manage data for multiple customers, each with it's own set of data. The userID is tied to a specific customer, to ensure that each customer can only view and modify his or her data.

So in the user table we collect userID, password, customerID with the sessionID being the PK. Same as the example + a customerID field.

On login, when the database hands out a new uniqueidentifier for the session, we know which user and which customer.

Now as long as you ensure that for each query you add the uniqueidentifier, the database can figure out for which customer data needs to be displayed.

On the ASP side, we do not need more than the ID, since the rest is done on the database side. As long as you ensure you always pass the ID as stored procedure parameter and make the ID available. So as far as reinistantiation of the session data on the pages, there is not any in our case

Reply With Quote
  #6  
Old June 24th, 2003, 09:50 AM
tomkelleher tomkelleher is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 3 tomkelleher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb

Quote:
So as far as reinistantiation of the session data on the pages, there is not any in our case


Ah! This makes more sense now.

You can imagine my confusion, I guess. Everyone programs a bit differently, but for most folks (I would guess), the Session object is valuable mainly for the ability to create and use Session variables for each user. The existence of a Session ID that you can use to track things is useful but kind of incidental.

So when the article's title seemed to promise a technique to replace the Session object, I was excited to see how you would use a database to store and maintain and reinstantiate Session variable data. But that was not the intent of the article. Perhaps a more to-the-point title for the article would have been "Session ID Replacement in ASP?"

In any case, thanks for explaining...

- Tom

Reply With Quote
  #7  
Old June 24th, 2003, 10:06 AM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 7
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
However, in the example the database takes care of the timeout value which comes in with the session variable.

We started out using session variables to store login information, and to check whether a user is logged in or not, reasons being to control how much idle time a user is allowed to have before the session should be considered closed, (Session.TimeOut) and whether a user is logged in or not.

That's why in the article the database checks the last update time, and our discussion above talks about the table which you access using the id.

Reply With Quote
  #8  
Old July 2nd, 2005, 01:23 AM
solomon_13000 solomon_13000 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 3 solomon_13000 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 10 sec
Reputation Power: 0
sSessionID

If sSessionID = -1 Then
SMessage = "username or password invalid"
else
Response.Redirect ("home.asp?id=" & sSessionID)
end if

when ever the username and password is incorect, then the -1 will be returned by the stored procedure, and the "username of password invalid" message will be displayed.

However when my username and password is valid, sSessionID has no value in it. Totally empty.

Im new with asp. How is it solved.

Reply With Quote
  #9  
Old July 2nd, 2005, 01:33 AM
solomon_13000 solomon_13000 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 3 solomon_13000 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 10 sec
Reputation Power: 0
Insert

I inserted the record into the table as in:

INSERT INTO tbl_users VALUES (NEWID(),"mama","papa",GetDate())

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Article Discussion: Session Replacement in ASP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT