I'd use this technique:

  1. User requests that link be generated
  2. A random string (such as 1234567890abcdef) is generated and stored with its time of creation. A database is the logical tool to use for this storage.
  3. The link is generated using that random string, probably in the query string. e.g. http://example.com/foo.cgi?user=dorward;token=1234567890abcdef
  4. Link is emailed to user

Then, when the link is activated, the CGI script would look up the string (I'd add a WHERE clause in the SQL query to say "where time created is greater then now - 24 hours"). If its the query returns a result, then the link is OK, otherwise the user gets an "invalid or expired link" message that suggests they check they copied it correctly (watch for word wrap) and offers them a chance to generate a new one.

A regular process (probably triggered by cron) would then delete old entries from the database.

This is the type of thing that would be used for mailing list conformation emails. I wrote something along those lines for a "Forgotten your password" section of a website.

The technique generates randomish tokens to identify users, but that is about as similar as it gets to sessions.


In reply to Re: Ideas for implementing download links that expire, via e-mails by dorward
in thread Ideas for implementing download links that expire, via e-mails by ghenry

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.