PHP session

Discussion in 'Troubleshooting' started by housey, Oct 4, 2010.

  1. housey

    housey New Member

    Joined:
    Oct 4, 2010
    Messages:
    5
    Hi,

    I have amember working great.

    The problem is when a user is logged in it shows their name and details in the page header but when they click on index which is not an amember secured page it shows the login box as if they're not logged in.

    I have code in there to check for the amember session login so it should not display the login box but their details.

    I do print_r($_SESSION); and get nothing. Seems really simple but really strange. I've searched the forums and found nothing. Can anyone help pls? :)
  2. mikecgi

    mikecgi Moderator

    Joined:
    Sep 7, 2010
    Messages:
    9
    try adding start_session(); at the top of the file, right after the first <?php opening tag...
  3. housey

    housey New Member

    Joined:
    Oct 4, 2010
    Messages:
    5
    Sorry I should have mentioned that is already in there...
  4. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    @housey:

    1) Are you switching between www and non www versions of your site (which would potentially change the session state)

    2) Are you switching between subdomains?

    3) Any 3rd party script (besides aMember) that might be interacting with session state?

    Are you saying that when you print_r($_SESSION) it returns blank or you just do not see the particular field you are looking for?
  5. housey

    housey New Member

    Joined:
    Oct 4, 2010
    Messages:
    5
    It was this. Silly mistake on my part. I have absolute links in my menu with no www.

    By the way does everyone use absolute links if they have a menu in their header.html. As this file for me is buried in a couple of sub dirs I have to, just wondering if that's general preactice with amember?

    Thanks for the help...
  6. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    @housey: thanks for the follow up. glad it is sorted out.

    I lock everything to the non www. version of the site (also enforced via htaccess)

Share This Page