Sharing Sessions between Rails & Php

Hey there everyone

Does anyone have any experience on this and if so could you please
guide me in the right direction?

I have a rails app which is password protected using acts as
authenticated
I want to use php for the uploads section of the app for the following
reasons:

  1. Php does not have problems with blocking like rails on file uploads
  2. Php/imagemagick is way less processor intensive than rails/rmagick
  3. I m potentially going to uploading video and processing with ffmpeg
    and for the two reasons above php would probably be more sensible.

I want to be able to check if a user is logged from within my php app
and this is how i am proposing to do it

  1. Log in via rails site, browse to image page
  2. grab the session id from rails and the user id and pass them to the
    php upload script. i am assuming rails will write a unique session
    identifyer file to /tmp ? or the same in the database
    for example the url for the php script might look something like this:

http://media.mydomain.com/images/upload.php?session=2139adfskjhagfdkj&user_id=12312

  1. from the php script check to see the user exists and the session
    exists for this user and do the image upload/processing
  2. redirect to the rails page

when the user logs out/session expires obviously the php would throw
an error and not work because the session would be deleted

Does anyone hae any experience with sharing sessions between rails and
php???
Is there any librarys for such?
what would be a more secure way of doing this?

thanks Adam

On 31 Jan 2008, at 01:28, Adam J. wrote:

I have a rails app which is password protected using acts as
authenticated
I want to use php for the uploads section of the app for the following
reasons:

  1. Php does not have problems with blocking like rails on file uploads

If you’re really that worried about the blocking (which hasn’t been a
problem for one of my apps at all, because it doesn’t block until
AFTER the upload is finished and I immediately hand it over to
backgroundrb), use Merb which allows you to use Rails sessions and
ActiveRecord and is multithreaded.

  1. Php/imagemagick is way less processor intensive than rails/rmagick

Use ImageScience if all you want to do is create thumbnails, or
minimagick, which uses ImageMagick via the command line.

  1. I m potentially going to uploading video and processing with ffmpeg
    and for the two reasons above php would probably be more sensible.

That’s what I’m doing in one of the custom apps I created,
backgroundrb handles that for me and it integrates better with Rails
than PHP.

This whole single threaded nature of Rails has been blown so out of
proportion that as soon as a beginning (or probably even more
seasoned) Rails developer hears “file uploads”, loud alarms start
ringing all over the place, everybody panics and starts running
around like a chicken without a head. Don’t, just don’t. It’s just
something you need to be aware of and use an elegant solution for,
not something to sign a pact with an old devil for.

Best regards

Peter De Berdt

On 31/01/2008, at 10:08 PM, Peter De Berdt wrote:

uploads
minimagick, which uses ImageMagick via the command line.
proportion that as soon as a beginning (or probably even more

Cheers Peter. appreciate your advice
I think i will run with merb for all uploads or investigate as you
said handing the image processing of to another thread.
I had also worked out how do do it in php just by grabbing the active
session_id from the cookie and the userid from a parameter and
checking against the user database to see there had been activity in
the last few mins (ie user was logged in)

Are you using rmovie or are you passing it straight to the command
line for ffmpeg?

regards Adam

On 31 Jan 2008, at 10:32, Adam J. wrote:

Cheers Peter. appreciate your advice
I think i will run with merb for all uploads or investigate as you
said handing the image processing of to another thread.
I had also worked out how do do it in php just by grabbing the
active session_id from the cookie and the userid from a parameter
and checking against the user database to see there had been
activity in the last few mins (ie user was logged in)

Are you using rmovie or are you passing it straight to the command
line for ffmpeg?

I’m using a straight command line call, works fine for my needs.

Best regards

Peter De Berdt

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs