|
There is not details nether explenation of what is doing.
|
|
|
|
|
Hi CoolVini,
I'm surprised to see the article at the end of 1st quater 2009 .
There were explanation earlier with the code, unfortunetly nothing is there now except one line.
I believe as this is a very old article, so codeproject team probably arhive the content.
Please download the code, and read the README text file, and feel free to meail me if you have any questions.
Wish you all the best.
Best Regards,
Himadrish
Himadrish Laha
|
|
|
|
|
Hi
"Simplest things generally are the best" is what I often try to recall while doing things (not only when coding). I must admit I didn't quite catch your point against using Session.SessionID, for instance.
As I understood your method relies on Session to be triggered. When triggered, a fuction call returns a new ID. Basically this means you get a new ID on every session, right? Which is exactly what SessionID does.
Both share the same disadvantages, e.g. SessionID uniqueness is not guaranteed for a single visitor (i.e. while unique since last IIS start a visitor might get different SessionIDs). Both ways also require browsers to accept cookies, which might not always be true.
Could you provide detailed explanation on your method? What is "the problem" you want to solve?
IMHO it is best to use integrated security to login users. There are some articles on MSDN that deal with it be it using SSL or other secured channels.
---
Vince C.
|
|
|
|
|
Well the problem is not for login user authentication or ssl, it is more than that. In production server, we have to give uniqueId for each session.
Now what session.Id IIS is produce may not be unique, or better to say, we never depends on this, so we have to generated id.
Now, we can not generate the id in session_OnStart, because, mismatch of same id will happened.
what we could is we just want to request a function call to generate the session id. Which will check to every senarion, that the sessionid is unique.
The code is very simple, and I think not a single line can be eliminated.
In this function, we just resist to enter more than one session user using two application variables, and there uniqueid is generated, and then application.unlock called.
So the very next session user in the queue will get next generatedID.
Hopes this will clear to everybody.
Regards,
Himadrish
Himadrish Laha
|
|
|
|
|
Ok, now I understand some more. Reading your reply to denic, I also understand you wrote a generic startup code. However it looks like you're turning a basically stateless application (IIS and web applications in general) into statefull application.
I think you may have to revisit this concept, mostly because of your serialized approach of unique IDs. You can optimize IIS and tune performance but this approach runs way against performance boost. In this case native support for concurrent access is disabled - or serialized.
The same limitations apply to storing single appartment-threaded COM into application variables. Method calls involve serialization. When the load increases performance downgrade occurs because of the overhead needed to serialize calls.
As I said integrated security is an example that might solve your need to get a unique ID for your users. There are also examples on how to pass state variables across pages using GET/POST.
---
Vince C.
|
|
|
|
|
... what's wrong with the simpler:
SUB Session_OnStart
Application.lock
Application("recordsid") = Application("recordsid") + 1
Session("ret") = Application("recordsid")
Application.UnLock
END SUB
Moreover, what's the point in the second line of the following? (you can safely delete it...)
Session("status")=false
Session("ret") = GetNewId()
while Session("status") = false
Session("ret") = GetNewId()
wend
|
|
|
|
|
Thogh I mail you, but for others, I put it for simplifications
=====================MAIL CONTENT============
UR QUERY:
=========
I don't understand this: after "application.lock" only one user can access the application variables, so if you assign session("") before application.unlock with an application variable you can be sure that no other user got the same application variable value. The "second" user should wait at the "application.lock line" until the "first" user has released the lock, so the second user can't get the same id value. Am I wrong about this? I'm quite interested in this, because I was well sure about that and if this is not true I have to recheck some software of mine...
My Comments:
============
Yes, when I use application.lock, no session user can not edit this variable, untill application.unlock. An the session variables 'Session("status")=true' used to exit out from while loops.
UR QUERY:
=========
Moreover, if you test application("ent") and application("work") outside an application.lock, you can't be sure they mantain the same value you checked "after" the check and before the lock, so the check is useless. Another user could be modified your application("ent") value "after" the first check and "before" the second check.
My Comments:
============
I used Application two variables. Now, think 2 user enter in the session, now two of them see 'Application("ent") = false' and 'Application("work") = false', now two of them get entered, now one of them only able to make 'Application("work") = true' and did the application.lock, in the meanwhile, sencond session user get allready it is lock, so he / she had to be wait untill application.unlock. I did not want to check this two application values in session, because in session they will get it false, and both of session user increment it(or may be the function will called), and mismash can happened. So that, I want to do it in one coomon area, that is in a function(). I have the problems, where more than 1000 user get in / out within 1 hr, and once in a time, they get same userID.
UR QUERY:
=========
Finally, in your function "GetnewId()" you don't assign any value to GetNewId, so it is not a function, it is a sub. in Sub Session_onStart your assignment
Session("ret")=GetNewId()
returns "empty" always. Maybe the code you submitted was not the original one?
My Comments:
============
well, in this function user / developer will assign the values according to need. I means may be some unique value will be generated for each visiting user. I just hard coded it into a variable, and increament it.
UR QUERY:
=========
My second remark is about this: if you write
1 Session("status")=false
2 while Session("status")=false
3 session("ret")=GetNewId
4 wend
line 3 is executed surely at least one time. You would be right if someone else could access the "Session()" variables, but only a user can access that, so it is impossible that two different users access the same session variable.
My Comments:
============
Session("status") will only access by one user. I just put this one, as to use it in while loop. Untill and unless user get the unique ID from databases(In actual projects), session user will be bounded on this while loop.
Now in while loop, we call the function, and here, I have to use application variables for this one.
Himadrish Laha
|
|
|
|
|
|
NO, SIR IT IS FULL FULL. PLS HAVE A GOOD DOWLOAD ACCELARATOR.
Regards,
Himadrish Laha
|
|
|
|
|