Skip to content

Instantly share code, notes, and snippets.

@tinotriste
Forked from Knivrobot/functions.php
Last active December 16, 2015 05:29
Show Gist options
  • Save tinotriste/5385149 to your computer and use it in GitHub Desktop.
Save tinotriste/5385149 to your computer and use it in GitHub Desktop.
Wordpress: Use session cookies
<?php
//Enable sessions i wordpress
if ( !session_id() )
add_action( 'init', 'session_start' );
?>
<?php
session_start();
if(isset($_SESSION['test'])) {
$_SESSION['test']='Hello again!';
} else {
$_SESSION['test']='First time here';
}
echo $_SESSION['test'];
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment