Notification:

The object of my meditation: to find most flexible, protected and simple in use solution and forget about this suxx forever. Insignificant admissible limitations for this solution are: non portable (only Unix), non secure against packet sniffering (this is a task for SSL). This solution must not depend on mod_perl and mod_rewrite (these modules not enabled on many web hostings) but work well with these modules.

Ideal solution must work automagically and not depend on used template system. Example of interface to such solution:

use POWER::Session; %userdata = load_session(); ... if ($need_to_store_something) { $userdata{something} = $somevalue; save_session(%userdata); }

The winning solution at this time use mangled URLs and symlinks. I'm never see before solutions with symlinks, so please meditate to find weakness which I don't see right now and find solutions for already known weakness.

Update:Now with readmore tag, thanx to pdcawley :)

In this table shown which features required for ideal solution. Legend:
Param mean using <INPUT TYPE=HIDDEN NAME=id_sess VALUE="1234567890"> in forms and /path/script.cgi?id_sess=1234567890 in URLs.
URL (after path) mean using /path/script.cgi/1234567890
URL (at root) mean using /1234567890/path/script.cgi
Feature/Method BasicAuth Cookie Param URL (after path) URL (at root)
Sessions for anonymous (not logged in) users NYYYY
Protect against malicious user enter into someone else's active session see below
Possibility to have many simultaneous logins for the same user from different browsers/hosts YYYYY
Possibility to have different sessions in different browser windows (to allow many simultaneous logins, for ex. as ADMIN and as USER) NNYYY
"Open in New Window" work without problems YY see below
"Back" button work without problems YYYYY
Custom login form (only password, or id+email, or ...) NYYYY
Work with disabled cookies in browser YNYYY
Work with disabled JavaScript in browser YYYYY
Do not affect search engines spiders YYY see below
Do not affect page relevance on search engines YYYY see below
Session work automagically, i.e. no necessity to programmer/designer keep in mind sessions and do something dull like adding session id to all forms and links YYNNY
Relative links in HTML (<A HREF="../index.html">) don't affect session YYNNY
I'm sure I forgot some of features, but I hope my idea is clear.

About some of these features:

Some details:at this time my sessions work this way:

  1. In the $ENV{DOCUMENT_ROOT} dir I create directory named "-". In this directory I create 257 symlinks:
    "-" points to "../"
    "00" points to "./"
    "01" points to "./"
    ...................
    "ff" points to "./"
  2. When NEW user request something like /path/info.html my cgi return to this user redirect to /-/01/e4/33/97/-/path/info.html.
    This way (with symlinks) it will work without mod_rewrite.
    This way still work all relative links inside info.html.
    And session is persist until user click on non-relative link.

In reply to Tired of session/cookie problem by powerman

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.