We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15001
    • 697 Posts
    Hi,

    For one site, I need to call the session_start() PHP function to see if the browser accepts cookies.

    As it tries setting a cookie through the HTTP header, this function must be called before anything else; even the DOCTYPE.

    I call session_start() from within a snippet.

    I assume that a snippet works exactly as if its PHP code was directly included into the webpage (although I know this to be impossible with MODx).
    Therefore there is no other place for my snippet call that the top of the MODx template I use.
    It seems however that session_start() works even when the snippet is called from another location.

    In the case of documents, I know that session_start() is already called by MODx.

    Maybe is session_start() robust enough to be called after the header without displaying errors and would simply have no influence in that case.

    So, I’m wondering if it is totally useless to call session_start() when using MODx and especially when running a snippet ?

    Who knows more about this ?

    Thanks.
      • 4080
      • 139 Posts
      Bump on this one! I have some legacy functionality for a newly "MODX-ified" site and it uses session_start() in one of the scripts. The legacy stuff on the front end (on MODX resource pages) ONLY works when I'm logged into the MODX manager. Otherwise it throws a 503 Page Not Found error. Halp!?
        • 4080
        • 139 Posts
        It looks like this thread (https://forums.modx.com/index.php?topic=27196.0) relates to my issue but it's from Evo's era. How do I get a different PHP session to coexist with how MODX (logging in and out of Manager) handles sessions by default?

        P.S. Using MODX 2.2.2-pl