Last active
July 18, 2016 14:17
-
-
Save victorknust/e862465b8e6bb6b5de4d8dc180b35796 to your computer and use it in GitHub Desktop.
WordPress Session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'init', 'example_session_start', 1 ); | |
| add_action( 'wp_login', 'example_session_regenerate' ); | |
| add_action( 'wp_logout', 'example_session_end' ); | |
| function example_session_start() { | |
| if ( !session_id() ) { | |
| session_save_path( '/mnt/data/www/example.com/sessions' ); | |
| session_name( uniqid( 'example-', true ) ); | |
| session_start(); | |
| } | |
| } | |
| function example_session_regenerate() { | |
| session_regenerate_id(); | |
| } | |
| function example_session_end() { | |
| session_destroy(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment