ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Protecting a EE template with aMemberPro php_include -- amember cookie not getting set

November 07, 2008 8:30pm

Subscribe [1]
  • #1 / Nov 07, 2008 8:30pm

    MotoNomad

    32 posts

    Anyone here have aMemberPro integration experience?

    I am adding Expression Engine to our existing aMember site.  (aMember 3.0.9 / EE 1.6.5) 

    I’m trying to “php_include” protect an Expression-Engine page which has download links to .PDF files in a new_rewrite protected directory.  (I want users to get logged in directly aMember in order to retrieve the new_rewrite protected file… )

    Any idea’s on how to get aMember ‘php_include’ protection to set the ‘amember_nr’ cookie from a EE template?

    $_product_id = array(1,3,4);
    include('/var/www/vhosts/website/httpdocs/amember/plugins/protect/php_include/check.inc.php');

    I added the aMember ‘php_include’ php code to my EE template… so far it:

    1. protects the page
    2. shows the aMember login form
    3. submits the login
    4. Returns to the EE page
    5. BUT incorrectly returns “Access to this membership area is not allowed. Please go to “Membership information page” to renew or add subscription” 

    At this point the following cookies are set:
    PHPSESSID
    exp_last_visit
    exp_last_activity
    exp_tracker

    6. If I go directly to /amember/member.php, it shows I’m logged-in, and sets these additional cookies:
    amember_nr
    exp_userhash
    exp_uniqueid

    7. NOW I can go back to the EE page and… It shows the protected content as it should.

    I can use the ‘php_include’ code on a non-EE .php page and it behaves as expected… Setting the amember_nr cookie and showing the protected content .

    Any idea’s on how to get php_include to set the amember_nr cookie from a EE template?
    I’ve tried changing PHP parsing stage from input to output and tried removing all EE code from the template.  I’ve been screwing with this for a few days…. trying all sorts of different setups.  I bought the ee_plugin and set it up…. but I’m not trying to log-into EE… I need to have user’s logged into aMember.  Leaving the EE generated download directory open to the public will cause confusion for our users.

    Any ideas or insight would be much appreciated!  (I cross-posted this to the aMember forums as well http://www.amember.com/forum/showthread.php?p=30111)

    Cheers!

    —Jason

    Mod Edit: Moved to the How To forum.

  • #2 / Nov 12, 2008 7:29pm

    MotoNomad

    32 posts

    Andrey of aMemberPro support found the solution:

    EE uses templates for include so your $_product_id is not global.

    Insert ‘global $_product_id;’ before product_id array

    Saved again by aMemberPro’s outstanding and responsive support!  Thanks Guys!


    So here’s what the code looks like now:

    global  $_product_id;
    $_product_id = array(1,3,4);
    include("/var/www/vhosts/doamin.org/httpdocs/amember/plugins/protect/php_include/check.inc.php");

    This allows a user to navigate directly to aMember protected EE content and Log into BOTH aMemberPro and ExpressionEngine.  (With aMember’s EE Plug-in.  )  This is MUCH much smoother from a user perspective.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases