Thread tagged as: Question, Api

PerchSession, Adding additional values

In my APP I would like to ADD a couple key/value to PerchSession.

Where is the best place to do this? (php script)

My guess is perch/addons/apps/my_app/index.php but I am wondering if there is already another way to do this?


    # include the API

    $API  = new PerchAPI(1.0, 'my_app');

    # include your class files

    # Grab an instance of the Lang class for translations
    $Lang = $API->get('Lang');

    # Do what you want to do before output is started
    PerchSession::set('KEY','VALUE'); // <==================== Is there a better way/place for this?

    # Top layout
    include(PERCH_CORE . '/inc/top.php');

    # Display your page

    # Bottom layout
    include(PERCH_CORE . '/inc/btm.php');
Robert Ketter

Robert Ketter 103 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The 'pre' in the x.pre.php file names means pre-output. So anywhere in your pre file should be fine.