• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generate Cookie Value

 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
What is the best way to generate the cookie value used when locking a record? I have read that some people suggest using the time however I was thinking of generating a random number.
Thanks
Chris
 
Tony Collins
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Random is the class you need to look at.
Tony
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tony,
Thanks, I just wanted to check that there was not a 'special' way of genarating cookie values that I did not know about.
Chris
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am genarating the cookie value using the Random class. However I have noticed a small problem. If two threads attempt to lock two diffrent records (at the same time) they end up with the same cookie value. I am putting this down to the fact that Random uses the System time as a seed. Can any one suggest a way of getting around this?
Thanks
Chris
[ September 27, 2003: Message edited by: Chris Harris ]
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
To get around the timing issue when genarating a random cookie value I have done :

instead of:

I have read that my new way is slower but i can not get the Random class to do what i want. What do you think?
Chris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic