PHP Integration

I have a 3rd party membership system (PHP based) that handles all of my
subscription duties. The system can protect a directory in one of two
ways either via .htaccess or a php include file.

The following rules are generated for a protected directory’s .htaccess
file:

########### START #####################
Options +FollowSymLinks
RewriteEngine On

allow access for product #5

RewriteCond %{HTTP_COOKIE} amember_nr=([a-zA-Z0-9]+)
RewriteCond /home/market5/public_html/members/data/new_rewrite/%1-5 -f
RewriteRule ^(.*)$ - [L]

if user is not authorized, redirect to login page

RewriteRule ^(.*)$
http://www.mydomain.com/members/plugins/protect/new_rewrite/login.php?v=
%1-5&url=%{REQUEST_URI}?%{QUERY_STRING} [L,R]
########### FINISH ####################

I can utilize the above to protect a given directory or there is the
option to protect a php page utilizing an include file.

How can I integrate the above .htaccess rules so that

  1. I don’t break any current existing RoR rules
  2. Certain authentication cookie values are available globally through
    my RoR application?

Any thoughts on the above would be greatly appreciated.