• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a uniqd id for users upload folder name

#2
When I create a user table, I assign a 'code' string to the user so I can refer to them in urls, something like users/view_profile/jfghdskjih so I would use that string (which is unique for each user and never changing) as the folder name.

I still use a piece of code suggested by Narf quite a long time ago for generating 'almost' guaranteed unique codes. I find it very useful and use it in some way on almost every site I do. Here it is in Narfs original form:

Code:
$code = bin2hex(pack('N', microtime(TRUE))).bin2hex(get_instance()->security->get_random_bytes(4));
https://forum.codeigniter.com/thread-634...#pid324949

I have a functions library full or things I find really handy that I transfer to all my sites and one of the functions in there is generate_code() which is the above function.

Just thought that might be of some use.
Reply


Messages In This Thread
RE: Creating a uniqd id for users upload folder name - by PaulD - 03-04-2017, 08:57 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.