page

sessions

VERSIONlatest Implement sessions for Extenso

SESSIONS(1e)

NAME

sessions - Implements sessions for Extenso

SYNOPSIS

session_get(key:string[, withexp: boolean]); session_set (key:string,value:string[,exp:string]); session_del (keys:string);

DESCRIPTION

These functions are used to implement a session.

session_set gets the current session cookie, the key passed in parameter and the expiration date if any and saves the value in the database. If the key already exists, it is replaced.

The database right now is mariadb and the table is sn_sessions. This might change in the future.

session_get retrieves a value corresponding to the key and the cookie of the user.

session_del is used to delete keys from the database.

PARAMETERS

key
key to store data.
exp
Expiration date in the format YYYY-MM-DD HH:MM:SS or in the form +… The operations is a +, followed by a number and then by a single character which can be:
  • s : second
  • m : minut
  • h : hour
  • d : day
  • w : week
  • b : month
  • y : year
value
Value for the key in string format.
withexp
If withexp is set to true, session_get will return an array with value and expiration date.

RETURN

session_get
returns the value.
session_set
returns -1 if cookie is not valid, -2 if a sql error occured and null otherwise.

EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

{_{ %include "/extenso/functions/sessions.snc"; }}

\{_{
session_set("captcha",c[1], exp:"+300s");
session_get("captcha");
session_del("key1","key2");
}}

AUTHOR

Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>