Yes, that's better, but it does guarantee that some users will not be able to use your site. The user might be sitting behind a proxy that uses a different IP address with every request. AOL users, for example, have a different IP address almost every time they connect. Thus, if anyone connects to your site using an IP address that someone else has used, they'll gain access to the other person's session.

You want to use some form of random session ID that times out. One caveat, though: do not use sequential IDs. If someone connects and has a session ID of "307920" and the previous person had "307919", then someone can easily change their cookie value to hijack someone else's session. Random session IDs that time out in a relatively short period of time stand the best chance of avoiding a session hijacking issue.

Also, I should mention that you want the session start time to be stored on the server and not relying on the "-expires" key in your cookie. You maintain control over the session timeout yourself and you don't have to worry about someone changing their clock on their computer (or worse, having a non-standards compliant browser ignoring the timeout value for the cookie).

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to Re: Re: Re: Re: (not so) Invisible Cookies by Ovid
in thread Invisible Cookies by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.