473,388 Members | 989 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

giving a unique random number for user identification

The only way i know is either using combinations like
Expand|Select|Wrap|Line Numbers
  1. var a=Math.round(Math.random()*1000000);
  2. var b=Math.round(Math.random()*1000000);
  3. var c=Math.round(new Date().getTime()/1000);
  5. d=a+""+b;
  6. e=a+""+c;
is there any other way to get a unique number with a very low probability of them being same
Sep 17 '07 #1
9 2384
5,390 Expert Mod 4TB
hi ...

the following should always generate a unique value:

Expand|Select|Wrap|Line Numbers
  1. var unique_val = + new Date;
kind regards
Sep 17 '07 #2
thanks gits

but its in my code
Expand|Select|Wrap|Line Numbers
  1. var c=Math.round(new Date().getTime()/1000);
Sep 17 '07 #3
5,390 Expert Mod 4TB
not exactly as you can see :) ... you kill the last 3 positions with dividing by 1000 and round the result ... that gives the chance to be not unique when its called too fast ... try it ;)
Sep 17 '07 #4
i know it gives result in milliseconds

but i want a different type of random number that is not math.random or new date

is there any other type of random number
Sep 17 '07 #5
5,390 Expert Mod 4TB
hmmm ... i don't know ... to be sure the timestamp is always unique ... even a random number might have a chance not to be unique ... but in case you want to have a 'pool' of numbers then you may create a list with numbers that you may assign to a user each time ... and assign that only once ...
Sep 17 '07 #6
thanks gits
ill try then combination of math.random and date object
i was checking if another type of random number exists
Sep 17 '07 #7
5,390 Expert Mod 4TB
can you tell the purpose of this? it's better to assign a number at the server i think ... because it is (might be) security relevant? ...
Sep 17 '07 #8
nope it is nothing security relevant
i am using this for behavioral targeting
if i get a unique visitor number i might be able to track them
and with so many request on server engine i cant use it to set a unique number every time a visitor visit the websites as it will increase the load
Sep 17 '07 #9
5,390 Expert Mod 4TB
i see ... so you assign the id to the user and track his behaviour with this id and may be he is getting proposals or special links or interfaces depending on his behaviour? :) ...

good luck with your project ... and post back to the forum anytime you have more questions,

kind regards
Sep 17 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

by: August1 | last post by:
A handful of articles have been posted requesting information on how to use these functions in addition to the time() function as the seed to generate unique groups (sets) of numbers - each group...
by: RCS | last post by:
We have sort of a centralized single-signon written in ASP.NET for all of our legacy ASP and ASP.NET apps.. There are around 1200 users and something like 2 dozen apps. Everyonce in a while, a user...
by: Nel | last post by:
From your (group) opinion, when sending a unique URL to a user, what steps are a must in making sure the link can't be hacked. i.e. Bad link www.example.com?id=10&action=reset_password ...
by: EP | last post by:
This inquiry may either turn out to be about the suitability of the SHA-1 (160 bit digest) for file identification, the sha function in Python ... or about some error in my script. Any insight...
by: Simon Wittber | last post by:
I'm building a web application using sqlalchemy in my db layer. Some of the tables require single integer primary keys which might be exposed in some parts of the web interface. If users can...
by: Robert Mago | last post by:
Is there a way to create a 10 characthers or less, alph-numeric string which is unique. I can't use the guid since its longer then 10 characthers. Also i cannot use a random number, since being...
by: Marc | last post by:
Hi all, I have to generate and send to a printer many 6 digit alphanumeric strings. they have to be unique but I cannot check in a database or something like that if it have already been printed....
by: Steven D'Aprano | last post by:
I have an application that will be producing many instances, using them for a while, then tossing them away, and I want each one to have a unique identifier that won't be re-used for the lifetime...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.