It's probably safest to both set a cookie and also put it in the query string. That means modifying every link you generate for the user.

Of course, that gives you really long and ugly URLs with a lot of noise in them.

So the first time you receive user's session ID in a cookie, you could set a "cookies work" flag in the user's session. From then on you can stop adding the session ID to the links you generate. If the user loses the cookie, you start them over with a new session.

Another strategy would be to start by assuming that cookies work. The first time you receive a cookie-less request for any page that isn't the main entry page to your site, you start adding the session ID to the query string.

Michael

In reply to Re: CGI Session question by magog
in thread CGI Session question 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.