Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Creating Web Sessions

From: ryan:christiansen:intellisol at: 25-May-2001 9:56

I use a system which creates a session ID based on the time and date USAGE: sessionID: make decimal! time-in-digits now Here is the time-in-digits function: time-in-digits: func [ "Convert the date and time from 'now' into a string of digits." sun-dial [date!] "The current date and time from 'now'" ][ year: to-string sun-dial/year month: to-string sun-dial/month if (length? month) < 2 [insert month "0"] day: to-string sun-dial/day if (length? day) < 2 [insert day "0"] current-time: sun-dial/time hour: to-string current-time/hour if (length? hour) < 2 [insert hour "0"] minutes: to-string current-time/minute if (length? minutes) < 2 [insert minutes "0"] seconds: to-string current-time/second if (length? seconds) < 2 [insert seconds "0"] rejoin [year month day hour minutes seconds] ] In the configuration section of the script, I set the session ID time-out to 10 minutes (based on using a string of digits representing the time) USAGE: sessionID-timeout: make decimal! 1000 Then whenever the user takes an action, I check the session ID and force them to login again if they had timed out. If they hadn't timed out, I renew the session ID. For example, here is code which checks the session ID before allowing the user to edit a piece of information... USAGE: either (check-sessionID cgi-input/sessionID sessionID-timeout) [ edit-message cgi-input display-messages/for-editing/with-search-form default-input ][ display-login-form cgi-input ] The code for the function 'check-sessionID follows: check-sessionID: func [ {Check a user's sessionID value to make sure it is still valid.} user-sessionID [string!] {The sessionID value as generated after login and continuously updated during a session.} sessionID-timeout [decimal!] {A decimal value representing the amount of time a user may be logged in to use administration functions without taking any action.} /local sessionID-check ][ user-sessionID: make decimal! user-sessionID sessionID-check: make decimal! time-in-digits now return either (user-sessionID + sessionID-timeout) > sessionID-check [ true ][ false ] ] -Ryan [stefan--falk--s] To: [rebol-list--rebol--com] Sent by: cc: rebol-bounce@ Subject: [REBOL] Creating Web Sessions 05/25/2001 09:33 AM Please respond to rebol-list Hi, I'm planning on creating a site (or part of a site) that requires a login and a password. It should also create a session, and if you would like to, send you a cookie so you don't have to login everytime. I've heard that cookie-sessions can be made automagically. Does anyone have an idea about how to do this? Has anyone had any experience in creating sites using sessions? /Regards Stefan "Syke" Falk -