in reply to Re^3: Perl and Cookies
in thread Perl and Cookies

ad 1/ Can the user establish two sessions at the same time?
ad 2/ Yes, I'v simplified my table - it has sequential primary key (aka ID) and the session identifier, I named it "token".
ad 3/ I prefer simple solutions, and when I am able to fully satisfy the requirement with 50 rows of code, I am not using the modules, having thousands rows, potentially with bugs.
You wrote that my way is not the great, but you did not write why :>))
In any case, thanks for sharing experience...

Replies are listed 'Best First'.
Re^5: Perl and Cookies
by radiantmatrix (Parson) on Mar 07, 2006 at 14:57 UTC

    Can the user establish two sessions at the same time?

    That's up to you. ;-) Nothing prevents it, though such things always take a bit of thought to do well.

    I prefer simple solutions, and when I am able to fully satisfy the requirement with 50 rows of code, I am not using the modules, having thousands rows, potentially with bugs.

    You're... not using modules? Because they might have bugs? I'm willing to bet that the mainstream modules suggested in this conversation have a better test suite than your code, and the advantage of hundreds or thousands of testers. Sorry to be blunt, but that's a really stupid reason to avoid CPAN.

    You wrote that my way is not the great, but you did not write why

    Because you were randomly generating data, then checking for collisions. The busier your site becomes under those conditions, the more likely a collision, meaning more re-checks. Your site becomes slower at a non-linear rate -- thus, bad idea.

    <-radiant.matrix->
    A collection of thoughts and links from the minds of geeks
    The Code that can be seen is not the true Code
    I haven't found a problem yet that can't be solved by a well-placed trebuchet
      No, that's up to you, when you construct sess_id from user name, time or such stuff...
      I'v never wrote that I don't use CPAN, and if you want, you can see my preference of short own code rather than some module stupid, I see the same as independancy.
      The probability of collisions when my id's are generated is, I know, but it is theoretical when more than 10 character length used. But if you check it against sessions in db when created, your action is the same as when checking the same session id given from the next request of the logged user. I cannot see relevant slowdown...
      I know that I am not perfect and my solutions really contains bugs, but somebody can be interested in.