How unique is the php session id

It’s not very unique as shipped. In the default configuration it’s the result of a hash of various things including the result of gettimeofday (which isn’t terribly unique), but if you’re worried, you should configure it to draw some entropy from /dev/urandom, like so ini_set(“session.entropy_file”, “/dev/urandom”); ini_set(“session.entropy_length”, “512”); search for “php_session_create_id” in the code for … Read more

Guid.Parse() or new Guid() – What’s the difference?

A quick look in the Reflector reveals that both are pretty much equivalent. public Guid(string g) { if (g == null) { throw new ArgumentNullException(“g”); } this = Empty; GuidResult result = new GuidResult(); result.Init(GuidParseThrowStyle.All); if (!TryParseGuid(g, GuidStyles.Any, ref result)) { throw result.GetGuidParseException(); } this = result.parsedGuid; } public static Guid Parse(string input) { if … Read more

UUID format: 8-4-4-4-12 – Why?

It’s separated by time, version, clock_seq_hi, clock_seq_lo, node, as indicated in the following rfc. From the IETF RFC4122: 4.1.2. Layout and Byte Order To minimize confusion about bit assignments within octets, the UUID record definition is defined only in terms of fields that are integral numbers of octets. The fields are presented with the most … Read more

SCOPE_IDENTITY() for GUIDs?

You can get the GUID back by using OUTPUT. This works when you’re inserting multiple records also. CREATE TABLE dbo.GuidPk ( ColGuid uniqueidentifier NOT NULL DEFAULT NewSequentialID(), Col2 int NOT NULL ) GO DECLARE @op TABLE ( ColGuid uniqueidentifier ) INSERT INTO dbo.GuidPk ( Col2 ) OUTPUT inserted.ColGuid INTO @op VALUES (1) SELECT * FROM … Read more

How to generate a GUID in Oracle?

You can use the SYS_GUID() function to generate a GUID in your insert statement: insert into mytable (guid_col, data) values (sys_guid(), ‘xxx’); The preferred datatype for storing GUIDs is RAW(16). As Gopinath answer: select sys_guid() from dual union all select sys_guid() from dual union all select sys_guid() from dual You get 88FDC68C75DDF955E040449808B55601 88FDC68C75DEF955E040449808B55601 88FDC68C75DFF955E040449808B55601 As … Read more

How to generate short uid like “aX4j9Z” (in JS)

See @Mohamed’s answer for a pre-packaged solution (the shortid package). Prefer that instead of any other solutions on this page if you don’t have special requirements. A 6-character alphanumeric sequence is pretty enough to randomly index a 10k collection (366 = 2.2 billion and 363 = 46656). function generateUID() { // I generate the UID … Read more

How to Create Deterministic Guids

As mentioned by @bacar, RFC 4122 ยง4.3 defines a way to create a name-based UUID. The advantage of doing this (over just using a MD5 hash) is that these are guaranteed not to collide with non-named-based UUIDs, and have a very (very) small possibility of collision with other name-based UUIDs. There’s no native support in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)