I have a web site I want to start selling products at. The site is entirely HTML with no use of any coding functionality other than JS. So far I'm planning to use Mals ecommerece site for the shopping cart aspect of it.
<!-- m --><a class="postlink" href="http://www.mals-e.com">http://www.mals-e.com</a><!-- m -->
To use this site I need to generate a unique "userid". Is using the Math.random() in JS the real only solution? Given the fact I only have JS capabilities at my disposal? My plan (so far) was to generate a number using random() and then set that value in a cookie for persistance or "session" purposes. Is this the best approach? The only approach?
Here's the code I was thinking of using...
function createUserID() {
var myNum = 0;
var myMax = 1000000;
do {
myNum = Math.floor(Math.random() * myMax);
alert(myNum);
} while(myNum < 100000 || myNum >= 1000000);
return myNum;
}
<!-- m --><a class="postlink" href="http://www.mals-e.com">http://www.mals-e.com</a><!-- m -->
To use this site I need to generate a unique "userid". Is using the Math.random() in JS the real only solution? Given the fact I only have JS capabilities at my disposal? My plan (so far) was to generate a number using random() and then set that value in a cookie for persistance or "session" purposes. Is this the best approach? The only approach?
Here's the code I was thinking of using...
function createUserID() {
var myNum = 0;
var myMax = 1000000;
do {
myNum = Math.floor(Math.random() * myMax);
alert(myNum);
} while(myNum < 100000 || myNum >= 1000000);
return myNum;
}