Cookies permit two separate sessions to be tracked even using the same authentication though. I might be merlyn with two separate shopping sessions going on, one for stuff I'm buying for work, and one for stuff I'm buying for the house.

Also, BasicAuth requires two trips to the server for each page, whereas cookies come up for free on the first hit, so server load is much lower with cookies. Ideally then, I'd authenticate using BasicAuth, and then a time-limited cookie gets thrown at me while I wander through non-authed (but cookie protected) pages.

Finally, every BasicAuth is transmitted in the clear, so this gives a sniffer that many more times to see the password. Do you really want your password being transmitted in the clear for each and every hit, or just once at the beginning of a session (perhaps in SSL) and then the rest of the session transmits just a session cookie? In fact, that'd be interesting to set two cookies, one that is used to track the shopping cart, but a completely different SSL-only cookie that is used for final checkout, so that the worst someone could do is put stuff in the cart, but not actually buy it. Hmm. Nice idea. I'll have to make a column on that. {grin}

-- Randal L. Schwartz, Perl hacker


In reply to RE: Answer: Security: Cookies vs HTTP authentication by merlyn
in thread Security: Cookies vs HTTP authentication by rodry

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.