[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

using PHP sessions in Ruby

Raphael Bauduin

3/4/2005 4:15:00 PM

Hi,

As more people out there, most or all my web developments are done with Ruby (Ruby on Rails, keeping an eye on Nitro).
As I can't rewrite all existing PHP apps, I've looked at a way to use PHP session with Ruby, and I've written a class parsing a
PHP session (PHPSessionParser) that you initialise with the string being the PHP session data.
I'm storing PHP session in a postgresql database (http://www.csh.rit.edu/~jon/projects/pgsql_sessio...) and I have written
a CGI session store to use the PHP sessions store in postgresql (called PHPDBIStore as it is using DBI, and not the postgresql driver
directly).

My employer agreed to let me publish it under the LGPL license. You can find the code at http://www.raphinou....

I'm not totally satisfied by the code design (if you look at the code, I'd like to not use the @working_str variable) but it's working for me.
You can store, modify, restore strings, arrays, hashes.

Feedback welcome. I'd like to know how you think this could be made better.

Thanks.

Raph
2 Answers

Raphael Bauduin

3/4/2005 4:21:00 PM

0

Raphael Bauduin wrote:
> Hi,
>
> As more people out there, most or all my web developments are done with
> Ruby (Ruby on Rails, keeping an eye on Nitro).
> As I can't rewrite all existing PHP apps, I've looked at a way to use
> PHP session with Ruby, and I've written a class parsing a
> PHP session (PHPSessionParser) that you initialise with the string being
> the PHP session data.
> I'm storing PHP session in a postgresql database
> (http://www.csh.rit.edu/~jon/projects/pgsql_sessio...) and I have
> written a CGI session store to use the PHP sessions store in postgresql
> (called PHPDBIStore as it is using DBI, and not the postgresql driver
> directly).
>
> My employer agreed to let me publish it under the LGPL license. You can
> find the code at http://www.raphinou....
>
> I'm not totally satisfied by the code design (if you look at the code,
> I'd like to not use the @working_str variable) but it's working for me.
> You can store, modify, restore strings, arrays, hashes.
> Feedback welcome. I'd like to know how you think this could be made better.
>
> Thanks.
>
> Raph

Little addition:

to use it with rails, edit config/environment.rb and add these lines (adapting usernames, passwords, etc):

require 'php'
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:database_manager => CGI::Session::PHPDBIStore, :user => "dbuser", :password => 'dbpassword', :dbi_url => 'dbi:Pg:php_sessions:dbhost', :session_key => "PHPSESSID")

If with php you kept the default setting for the session key, you'll be reusing your php session immediately.

Raph

George Moschovitis

3/5/2005 7:43:00 AM

0

Looks interesting, I will check this out.

-g.