v5:session:session_index
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
v5:session:session_index [2023/03/23 18:09] – Remove NOTOC dregad | v5:session:session_index [2024/10/08 09:21] (current) – [Using Encrypted Sessions] dregad | ||
---|---|---|---|
Line 85: | Line 85: | ||
and you are NOT using oci8 driver | and you are NOT using oci8 driver | ||
- | ==== Usage Examples | + | ==== Non-persistent Connections==== |
- | To force non-persistent connections, | + | To force non-persistent connections, |
<code php> | <code php> | ||
- | |||
include_once " | include_once " | ||
$driver | $driver | ||
Line 99: | Line 98: | ||
ADOdb_Session:: | ADOdb_Session:: | ||
- | ADOdb_Session:: | + | ADOdb_Session:: |
session_start(); | session_start(); | ||
- | |||
</ | </ | ||
==== DSN Support ==== | ==== DSN Support ==== | ||
Line 115: | Line 113: | ||
===== Using Encrypted Sessions ===== | ===== Using Encrypted Sessions ===== | ||
- | To use a encrypted sessions, replace the file '' | + | To use encrypted sessions, replace the file '' |
<code php> | <code php> | ||
Line 148: | Line 146: | ||
==== MySQL or PDO MySQL ==== | ==== MySQL or PDO MySQL ==== | ||
- | | + | |
- | CREATE TABLE sessions2( | + | < |
- | | + | CREATE TABLE sessions2 ( |
- | | + | sesskey VARCHAR( 64 ) COLLATE utf8mb4_bin |
- | | + | expiry DATETIME NOT NULL , |
- | | + | expireref VARCHAR( 250 ) DEFAULT '', |
- | | + | created DATETIME NOT NULL , |
- | | + | modified DATETIME NOT NULL , |
- | | + | sessdata LONGTEXT, |
- | | + | PRIMARY KEY ( sesskey ) , |
- | | + | INDEX sess2_expiry( expiry ), |
- | ) | + | INDEX sess2_expireref( expireref ) |
+ | ) | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | When [[https:// | ||
+ | Collisions could occur in this case, due to MySQL performing case-insensitive searches by default. | ||
+ | To avoid that, the //sesskey// column should use binary (or a case-sensitive) collation. | ||
+ | </ | ||
==== PostgreSQL ==== | ==== PostgreSQL ==== | ||
Line 197: | Line 204: | ||
===== Notifications ===== | ===== Notifications ===== | ||
- | You can receive notification when your session is cleaned up by the session garbage collector or when you call session_destroy(). | + | You can receive notification when your session is cleaned up by the session garbage collector or when you call //session_destroy()//. |
- | PHP's session extension will automatically run a special garbage collection function based on your php.ini session.cookie_lifetime and session.gc_probability settings. This will in turn call adodb's garbage collection function, which can be setup to do notification. | + | PHP's session extension will automatically run a special garbage collection function based on your php.ini session.cookie_lifetime and session.gc_probability settings. This will in turn call ADOdb's garbage collection function, which can be setup to perform |
- | PHP Session --> ADOdb Session | + | |
- | GC Function | + | GC Function |
- | executed at | + | executed at |
- | random time | + | random time |
+ | Extension | ||
When a session is created, we need to store a value in the session record (in the EXPIREREF field), typically the userid of the session. Later when the session has expired, just before the record is deleted, we reload the EXPIREREF field and call the notification function with the value of EXPIREREF, which is the userid of the person being logged off. | When a session is created, we need to store a value in the session record (in the EXPIREREF field), typically the userid of the session. Later when the session has expired, just before the record is deleted, we reload the EXPIREREF field and call the notification function with the value of EXPIREREF, which is the userid of the person being logged off. | ||
Line 231: | Line 239: | ||
system(" | system(" | ||
} | } | ||
- | </ | + | </ |
- | NOTE 1: If you have register_globals disabled in php.ini, then you will have to manually set the EXPIREREF. e.g. | + | |
+ | <WRAP info> | ||
+ | EXPIREREF | ||
<code php> | <code php> | ||
Line 239: | Line 249: | ||
</ | </ | ||
- | NOTE 2: If you want to change | + | In older versions of ADOdb this could be achieved automatically through |
+ | </ | ||
+ | <WRAP info> | ||
+ | If you want to change the EXPIREREF after the session record has been created, you will need to modify any session variable to force a database record update. | ||
+ | </ | ||
===== Neat Notification Tricks ===== | ===== Neat Notification Tricks ===== | ||
v5/session/session_index.1679591370.txt.gz · Last modified: 2023/03/23 18:09 by dregad