跳转到主要内容

omni_session

Session management

omnigres : Session management

Overview

ID Extension Package Version Category License Language
2966 omni_session omnigres 0.2.0 FEAT Apache-2.0 C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
----d-- No No No Yes no no

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 0.2.0 18 17 16 15 14 omnigres omni_var, omni_id, omni_web, omni_httpd, omni_polyfill
RPM PIGSTY 20251108 18 17 16 15 14 omnigres_$v -
DEB PIGSTY 20251108 18 17 16 15 14 postgresql-$v-omnigres -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64 PIGSTY 20251108 PIGSTY 20250120 PIGSTY 20250120 PIGSTY 20250120 PIGSTY 20250120
el8.aarch64 PIGSTY 20251108 PIGSTY 20250120 PIGSTY 20250120 PIGSTY 20250120 PIGSTY 20250120
el9.x86_64 PIGSTY 20251108 PIGSTY 20250507 PIGSTY 20250507 PIGSTY 20250507 PIGSTY 20250507
el9.aarch64 PIGSTY 20251108 PIGSTY 20250507 PIGSTY 20250507 PIGSTY 20250507 PIGSTY 20250507
el10.x86_64 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108
el10.aarch64 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108
d12.x86_64 PIGSTY 20251108 PIGSTY 20250120 PIGSTY 20250120 PIGSTY 20250120 PIGSTY 20250120
d12.aarch64 PIGSTY 20251108 PIGSTY 20250120 PIGSTY 20250120 PIGSTY 20250120 PIGSTY 20250120
d13.x86_64 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108
d13.aarch64 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108
u22.x86_64 PIGSTY 20251108 PIGSTY 20250120 PIGSTY 20250120 PIGSTY 20250120 PIGSTY 20250120
u22.aarch64 PIGSTY 20251108 PIGSTY 20250120 PIGSTY 20250120 PIGSTY 20250120 PIGSTY 20250120
u24.x86_64 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108
u24.aarch64 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108
u26.x86_64 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108
u26.aarch64 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108 PIGSTY 20251108

Source

docs.omnigres.org/omni_session/session_management/

pig build pkg omnigres;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install omnigres;		# install via package name, for the active PG version
pig install omni_session;		# install by extension name, for the current active PG version

pig install omni_session -v 18;   # install for PG 18
pig install omni_session -v 17;   # install for PG 17
pig install omni_session -v 16;   # install for PG 16
pig install omni_session -v 15;   # install for PG 15
pig install omni_session -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION omni_session CASCADE; -- requires omni_var, omni_id, omni_web, omni_httpd, omni_polyfill

Usage

omni_session: Session management

The omni_session extension provides standardized session management, creating an unlogged omni_session.sessions table for active sessions. Works primarily with the HTTP stack.

Session Handler for HTTP

Request handler – Extracts session UUID from a _session cookie:

SELECT omni_session.session_handler(request);
-- Optional: session_handler(request, cookie_name => 'my_session')

Creates a new session if the cookie is missing or invalid, sets the omni_session.session transaction variable.

Response handler – Sets the session cookie on the response:

SELECT omni_session.session_handler(response);

Cookie parameters:

Parameter Default Description
cookie_name _session Cookie identifier
http_only true Prevents JavaScript access
secure true HTTPS-only
same_site Lax Cross-site behavior
domain null Domain scope
max_age null Lifetime in seconds
expires null Expiration timestamp
path null URL path scope

Direct Session ID Handling

-- Create or validate a session:
SELECT omni_session.session_handler(null::omni_session.session_id);
-- Returns new session ID and sets omni_session.session transaction variable