Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Man or may not be usefull:
$time = time * (int(rand 200) + 1); $session = substr($time, 4, 4) . substr($time, 5, 4); $session =~ s/(\d\d)/substr("ABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAVA +WAXAYAZCACBCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCVCWCXCYCZDADBDCDEDFDGDH +DIDJDKDLDMDNDODPDQDRDSDTDVDWDXDYDZYAYBYCYDYEYFYGYHYIYJYKYLYMYNYOYPYQY +RYSYTYVYWYXYZQAQBQCQDQEQFQGQHQIQJQKQLQMQNQOQPQRQSQTQVQWQXQYQZ",$1, 2) +/eg; substr($session, int(rand 5) + 1, 1) = int(rand 9);

Essentually, take the current time (in EPOC) convert that to random letters, and save it in $session. You can then push that as a cookie or form element, as well as save it to the database table. This would handle a session, and should never ever be the same for any two users. As far as putting URI's or other info into the $session handler, I'd go with either adding more cookie entries or form field enteries. Keep in mind, users are nasty. They will do anything to keep there information private. So, adding a check for the cookie before processing is the best way to go, if the check fails and your database shows an entry saying that the user is logged in, then check the form fields, if they block both then there probibily blocking javascript, thus chances are, there not going to effectivily be able to use any web site that requires session id's or form information.

The coding is far from perfect and far from a solution. Just adds an alternative. You could, alternativily, catch the calling IP from the users broswer informaition (that usually is available even when everything else isn't), and use that with your database to handle the sessions. Meaning, if the user comes from the IP 127.0.0.1, and cookies are not present, javascript doesn't work, and form fields arn't comming through, save the IP to the database, and refer to the IP from the browser and database to confirm sessions. No two IP's should ever be the same. Id also send a message to the user, in the html document, telling them that cookies should be allowed for the site in order to effectivily use it. If they don't what to allow cookies, then why are they even visiting the site and using the functions....

In reply to Re: How do you do sessions in Web Sites by Delusional
in thread How do you do sessions in Web Sites by digiryde

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-28 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found