hi tabish,
See random number generation is nothing but maintaining a session ..but a little different way
When the user logs in, you verify his details and dynamically generate a ID and store them on the server ...If at all you feel confused you take it for granted that you store them in a DB..along with identities of the user .
After generating the random number you try to send to all the out going links as and additional parameter e.g.
http://something.com?rand=#76mbkj%*&
or else if you are validating any form then send as a hidden type variable..
When the user signs out then delete the random variable or make it to null.
Remember this is only safe if at all you validate the request in every page..If at all your are not targeting all age groups then ,you better go for Cookies..they are simple and easy, you need not bother about all this set a cookie under root directory then every thing is finished.
OR one more way you can do, you do programing in such a way that you find out which browser cant load cookie in the first visit to your web site and to that clientile you assign the random numbers...
Be careful handling all this ..as either one of them should be there ...but not both..It would be a little lengthy programing but definitely a useful and forever one.I mean the last one.
Good Luck.
s.r.k.reddy