I don't care for this method, as one is forced to try to reliably parse all links in documents.
This is the most reliable. It's easy to use and doesn't matter if the user leaves your site and returns later. However, if your Web site is dedicated to the premise that "BATF employees are bunch of jack-booted thugs", many of your users are probably concerned about privacy and have cookies disabled.
I like this method, but it only works across a series of form submissions. If the user leaves your site and returns later, state information is probably lost.
Re: MD5. According to this node, if you use MD5, you should run it twice to prevent someone from duplicating your key with different information. In fact, the aforementioned book points out that theoretical vulnerabilities have been discovered in the MD5 algorithm. As a result, I recommend Digest::SHA1. It does not have these vulnerabilities. Even if it is slower than MD5, it's probably faster than running MD5 twice, though I have not benchmarked it.
If you're interesting in using user information to generate a digest, the following algorithm is listed:
Further, here's a quote from the book regarding this method:use Digest::MD5; my $md5 = new Digest::MD5; my $remote = $ENV{REMOTE_ADDR} . $ENV{REMOTE_PORT}; my $id = $md5->md5_base64( time, $$, $remote ); $id =~ tr|+/=|-_.|; # Make non-word characters URL-friendly
This does a good job of generating a unique key for each request. However, it is not intended to create keys that cannot be cracked. If you are generating sessions identifiers that provide access to sensitive data, then you should use a more sensitive method to generate an identifier.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just go the the link and check out our stats.
In reply to (Ovid) Re: sessions: MD5 versus random strings
by Ovid
in thread sessions: MD5 versus random strings
by markjugg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |