We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40541
    • 85 Posts
    Sure there is a very simple answer to this (but I hope there isn't smiley, but I cant seem to make a session variable available to another snippet.

    The code is as follows:

    	$_session['searchResult'] = $_POST['search'];
    	echo '<p>Session search = ' . $_session['searchResult'] . '</p>';
    


    This works fine as running the snippet echo's out search.

    The next part follows as per below where I am using href to call a snippet to delete a row in the database:

    <a href="[[~[[*id]]? &callid=`[[+callid]]` &diallednumber=`[[diallednumber]]']]"><button type="button" class="btn btn-danger">Delete</button>


    Where the following snippet picks up on the $_GET

    if(isset($_GET['callid'])){
            $id = $_GET['callid'];
    	$deleteRow = $modx->myDB->getObject('LogData',array('callid' => $id));
    	echo $id . '<p> has been deleted</p>';
    	echo '<p>Session search = ' . $_session['searchResult'] . '</p>';
       return;
    };
    


    But I get the following error:

    Notice: Undefined variable: _session in /home/sites/paradoxal.co.uk/public_html/nhs/core/cache/includes/elements/modsnippet/25.include.cache.php on line 18

    Reading various posts I beleive I have done things correctly, also followed bobs guide http://bobsguides.com/modx-snippet-faq.html under 'How can I save a variable in a snippet so other snippets can use it?'

    Thanks in advance

    This question has been answered by sottwell. See the first response.

    • discuss.answer
      $_SESSION, not $_session.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 40541
        • 85 Posts
        Thats was my worst fear, something simple. Sorry about that. Thanks anyway.
        • Not a problem. I do that kind of thing all the time wink
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org