Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i automaticly give a customer a own ID ...

Status
Not open for further replies.

Beracosta

Programmer
Oct 25, 2000
47
SE
I wanna now how i can give a custumer a own generated id and put it in a cookie so the custumer always has the same id when he/she comes to my page... can some one help me?

(btw... the id should be stored in a database to) =)
 
If you have an autonumber filed in a database that is generated when you enter customer details then you can use that as an output parameter.
Another option is to use an Application variable and then read the start value from a database when the Application starts in the
Code:
Application_OnStart
event procedure in the Global.asa and then write the current value back to the database in the
Code:
Application_OnEnd
event procedure in the Global.asa.
To maintain consistancy you would issue the following code in your ASP page when issuing the user id:

Code:
Application.Lock
intID = Application("NextID")
Application("NextID") = Application("NextID") + 1
Application.Unlock

This assumes that the next user id is stored in the Application variable
Code:
NextID
.

Then to set a cookie you would use the following:

Code:
Response.Cookies("UserID") = intID

Assuming that intID contains the newly generted user-id that you want to store.

James Culshaw
jamesculshaw@active-data-solutions.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top