$_SESSION variable is blank on non-amember pages

Discussion in 'Integration' started by glacius, Jan 13, 2012.

  1. glacius New Member

    Member Since:
    Jan 11, 2012
    Message Count:
    24
    I found quite a few topics on the amember forums about this, as well as more in google, but I still seem to not be able to get a solution working.

    If I print or echo the $_SESSION variable on an amember page, I get an array with a ton of stuff in it (username, password, etc......)

    When I'm on one of my own pages and I try to print the $_SESSION variable I just get: "array ( )" and its as if there is nothing in the $_SESSION when referencing it from one of my pages.

    I am using developer on localhost.

    My a member pages are in localhost/ss/amember/*
    My personal pages are in localhost/ss/*

    I have a page called localhost/ss/test.php which looks like:

    And it outputs:

    This is due to the $_SESSION being just an empty array when I print it on the test.php page.

    When I modify layout.phtml in the amembers page and print $_SESSION out there, then the top of the page has an array ( <ton of variables here> ) and it look proper.

    So far I've made sure that I've included the session_start(); at the top of the page (as you can see above test.php is just a very simple page that does not work).

    I've looked in the config to get the phpinfo() and compared to phpinfo() in test.php and there are some differences, but looking up those differences, nothing I could pin point.

    localhost/ss/test.php:
    from amember admin area:

    I feel like it is something simple that I am just missing, or hoping something that someone else had dealt with and found the answer.

    I'm using XAMPP locally for running the above.

    Thanks for any help.
  2. glacius New Member

    Member Since:
    Jan 11, 2012
    Message Count:
    24
    Ok, still no luck.

    I am printing out session_id() on the amember pages and get a long string of numbers and letters.

    I am printing out session_id() on the non-amember pages (test.php) and I get the identical string so everything looked ok there.

    Still, print_r($_SESSION); is blank on test.php and filled with lots of goodies on the amember pages.

    That being said, I found this article:

    http://www.amember.com/forum/threads/session-variables.13842/

    And on test.php,

    Will, in fact, print out the username of the person logged in. This is great since I should be able to show the user who is logged in at the top of all of my pages now like I wanted. However, I would still like to know if this is correct behavior for the $_SESSION variable on non-amember pages. Maybe it is a security thing?

    Any clarification would be appreciated.
  3. alexander Administrator

    Member Since:
    Jan 8, 2003
    Message Count:
    5,849
    Yes this is correct behavior, because you try to use code from aMember v3.And it will not work with aMember v4.
    have a look how you can do this for v4: http://www.amember.com/docs/API/Lite

Share This Page