Protecting content within a page.

Discussion in 'Templates customization' started by rmsinfo, May 22, 2004.

  1. rmsinfo

    rmsinfo New Member

    Joined:
    May 22, 2004
    Messages:
    11
    Hi All,
    I'll ask here before I go off bothering other folks ...

    First, some setup information. Site in PHP, and typical page will look like this:
    <?php
    some variables set here
    ?>

    <? include the header file ?> (that contains the left side, and top of the page)

    The contents of the file here. You know, click this link, click that link.

    <? include the footer file ? (That contains the bottom of the page)

    Now, what I want to do, hope to do, without redoing my entire site, is have content available for those who have logged in.

    I've gotten it to work by placing
    ?php
    session_start();
    if($_SESSION[_amember_login]) {
    $ismember = "1"; }
    else { $ismember = "0"; }
    ?>

    At the top of the page (before the header include).

    However, if I place that same code in the header file, I get the error message "Warning: Cannot send session cache limiter - headers already sent"


    Keep in mind I know enough PHP to really mess things up. (Read: I don't know if there is a PHP limitation that prevents me from doing this, that I don't know about.)

    I hope that is enough information. If more is needed, please let me know.
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
  3. rmsinfo

    rmsinfo New Member

    Joined:
    May 22, 2004
    Messages:
    11
    So I guess the next obvious question is, do I need the session_start(); in there in order to make that work? (I could go try that out on my own, huh?)
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Yes, add it BEFORE ANY OUTPUT. then everything works.

Share This Page