When someone logs on to my transactional site I want to assign them an "Order Number" (which is unique) when they start a session. I assume I need some code in my Global.asa. Whats the easiest way to do this.
why not use the session id that asp creates for each session - session.sessionID?
Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
____________________________________________________
[sub]The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-2924[/sub]
Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
I dont mean to press this point but I've just read in a book on ASP that:
"the session ID should not be used as a primary key in a database because because it may not always be unique. For example if the Web Server is restarted, the server may assign a sessionID that was previously assigned to a different user."
Has IIS changed in recent versions to correct this? Any thoughts?
Please correct me if i'am wrong but I do try
I have never done this before but here goes!!!!!!!!
In the global asa put the following sub:
Sub Session_OnStart
end sub
This will be run when a new session is created.
Then create a text file which contains a 0
Then use the file system object in the sub to read from the text file. After it has been read cast it to a Long.This will be you id.Then assign it to a session variable.
Write this value back after you have incremented it to the text file after you have deleted the old one.
Well thats sort of the what I think should happen.
Hope it works!
bowettwow
you had not mentioned anything in regards to a database prior to the last post. although I think the chances of the sessionID being duplicated are slim to none it would be senseless to use anything but a autonumber for your primary ID in the DB. That is what it is for! It's safe, stable and conventional database design.
____________________________________________________
[sub]The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811[/sub]
bowettwow : If you have a Database, onpnt's idea will definatly work the best. It will cut the overhead of reading and writing to the text file as well as the creation of the FSO object.100% faster and safer.
But how would I pass the unique id to a session variable from an autonumber in my database. I'd somehow have to add a record to the database and then read what autonumber the database assigned it - how could I do this?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.