?
Solved

Unique Identifier for Online Application

Posted on 2007-08-06
7
Medium Priority
?
658 Views
Last Modified: 2013-12-24
I am writing an online application where I need to make sure everyone applying gets a unique identifier.  Right now I am using the date and time but I am not comfortable with it.  Right now two people could potentially grab the same number.  

I've read where people recommend ID & Token, but do not know how to implement.  Could someone give me some simple logic for this?  Thanks for helping.  I am using CF7.

What I am using now:
<cfset todaydate = DateFormat(now(), "yyyymmdd")>
<cfset todaytime = TimeFormat(now(), "hhmmss")>
<cfset UniqueNO = '#todaydate##todaytime#'>
0
Comment
Question by:sulzener
  • 3
  • 2
  • 2
7 Comments
 
LVL 25

Accepted Solution

by:
dgrafx earned 1300 total points
ID: 19638207
<cfset UniqueNO = CreateUUID()>
Guaranteed to be unique!
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 19638834
You could also just use the database.  When you said "everyone applying..." makes me think there will be a database record of the transaction.

The primary key of the table would be unique.

create table applicants (
   applicant_id    int    identity(1,1)   not null
   ...

0
 

Author Comment

by:sulzener
ID: 19641136
Okay, both suggestions work.  dgrafx (#1), answered the question and gdemaria (#2) got me thinking a different direction.   Let me ask a little deeper question.
I like #1 because I didn't plan to write the record until the very end.
I like #2 because the number is smaller and I want to use it for a couple things.

1) The user is attaching two files to the application.  I am using the application no. as part of the file name.
2)  Also, I'd like to use the number as a tracking number for status lookup capabilities.  #1 creates a huge number.  #2 could be a little small.

Does this peek any additional reseponses?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 39

Assisted Solution

by:gdemaria
gdemaria earned 700 total points
ID: 19641205

 Don't know how you're doing your application, but the right answer may be "both" methods.

 Once the record is created in the database, I would definately want to be referring to related files and child tables using the primary key of the table and have files and child tables use a foreign key to point to it.

 However, until the user has gone far enough to create the database record, you need to keep track of his information.  This can be done using session variables, form field variables and the session ID that dgrafx mentioned can be a substitute for the primary key prior to its initial insert.

 But I'm curious?   If you're not saving the data into a table yet, why do you need a unique identifier at all ?    What does the unique ID point to exactly?    Typically, if I am collecting information the user is providing, prior to their final  "save" button being pressed, I would do one of two things...

1)  save the data in the tables anyway, just have a status flag indicating that its "work in progress".   This allows them to return later and finish or take up after a crashed browser.   If the user doesn't finish, you just sweep through and clean up all the records the unfinished status that are X days old.

2) use client, session, form variables or cookies to maintain the database until its time to save the information into the database.  Which variabel depends on how much data there is and what hoops you have to jump through to get it.

So, I'm curious how you're doing it and what the session ID will be used for?
thanks,.

0
 

Author Comment

by:sulzener
ID: 19641591
Phase 1 of the project was to collect the info, email it.  Didn't need to save it.  The unique number was used to basically name the uploaded PDF files, hold them for emailing purposes only.
In Phase 2, I need to write data to a db, build a tracking portal for internal and external users. The external user will see status only.  The internal user will see everything.  
I am now working on Phase 2.  I like your suggestion of "work in progess" and even using both methods.  
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 19646030
hello ...
After reading the posts since I posted
it looks like you have 2 different needs.
for a unique ID in the db I'd definately go with the identity column in db
but your pdf naming may be a different thing
can each user get more than one pdf?
if so - then you can't use the one identity columns value to name several pdfs
so i guess my opinion would go something like this
<cfset UniqueNO = CreateUUID()>
<cfquery ... name="newUser">
insert into tableusers
(pdfNo,Email,whatever)
values
('#UniqueNo#', '#Email#', '#whatever#')

Select Needed Columns
From tableusers
where UserID = @@Identity <!--- UserID is your identity column --->
</cfquery>

then your code to write your pdf ....
use your UniqueNo to name it

then your code to email the pdf to this user
<cfmail ... query="NewUser">
Hello ... Here is some spam and a malicious macro from us
<CFMAILPARAM FILE = "#directorypath_to_your_pdf_dir#\#UniqueNo#.pdf"><!--- add a if fileExists probably --->      
</cfmail>

good luck ...
0
 

Author Comment

by:sulzener
ID: 19646712
Thank you both for your comments.  They were excellent.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question