public

  • Download Gist
limonade-snippet.session-feature.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
<?php
// LIMONADE SESSION FEATURES EXAMPLES
require_once 'lib/limonade.php';
 
 
function configure()
{
// by default, session is enable. It automaticaly start a session with LIM_SESSION_NAME as name
option('session', false); // disable
option('session', true); // enable
option('session', 'my_session_name'); // enable with a specific session name
}
 
dispatch('/', 'example_index');
function example_index()
{
// now you can manage session vars as normal
$_SESSION['my_var'] = 'my_value';
return html( '<p><a href="'
. url_for('page_two')
. '">Go to page two</a></p>' );
}
dispatch('/page_two', 'example_two');
function example_two()
{
// now accessing previously set session variable
$my_var = $_SESSION['my_var'];
// ...
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.