Re: Storing PHP 5.3 sessions into PostgreSQL 8.4

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Storing PHP 5.3 sessions into PostgreSQL 8.4
Date: 2011-09-21 15:03:53
Message-ID: 4E79FCD9.60100@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 21/09/2011 15:53, Alexander Farber wrote:
> Hello,
>
> I'm using CentOS 6.0 Linux 64 bit with the stock packages:
>
> # rpm -qa|grep php
> php-cli-5.3.2-6.el6_0.1.x86_64
> php-5.3.2-6.el6_0.1.x86_64
> php-xml-5.3.2-6.el6_0.1.x86_64
> php-pgsql-5.3.2-6.el6_0.1.x86_64
> php-pear-1.9.0-2.el6.noarch
> php-pdo-5.3.2-6.el6_0.1.x86_64
> php-common-5.3.2-6.el6_0.1.x86_64
>
> # rpm -qa|grep postgres
> postgresql-devel-8.4.7-1.el6_0.1.x86_64
> postgresql-docs-8.4.7-1.el6_0.1.x86_64
> postgresql-libs-8.4.7-1.el6_0.1.x86_64
> postgresql-8.4.7-1.el6_0.1.x86_64
> postgresql-server-8.4.7-1.el6_0.1.x86_64
>
> and would like to change my own PHP script from using
> $_SERVER['REMOTE_USER'] to using $_SESSION,
> but don't have any experience with PHP sessions yet.
>
> I'd like the (quite extensive) user data to be stored into
> the PostgreSQL and only save a "user id" in $_SESSION.

I think it's an all-or-nothing thing: if you want to save the session to
the DB, then everything in $_SESSION goes in.

You can easily replace the default session handler in PHP with your own:

http://www.php.net/manual/en/function.session-set-save-handler.php

This is what Drupal does, for example, to save the session in the DB.

You probably need to read up a bit more on sessions in PHP:

http://www.php.net/manual/en/book.session.php

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-09-21 15:20:17 Re: Upgrade extension from 8.4 to 9.1
Previous Message akp geek 2011-09-21 15:02:46 Re: psql with option -c fails..