Created
February 16, 2015 01:10
-
-
Save mAAdhaTTah/b610bb3833d1689198ba to your computer and use it in GitHub Desktop.
Using $_SESSION to Display Errors
This file contains 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
if ( array_key_exists( 'my_plugin_errors', $_SESSION ) ) { | |
foreach( $_SESSION['my_plugin_errors'] as $error ) {?> | |
<div class="error"><p> | |
<?php echo $error; ?> | |
</p></div><?php | |
} | |
unset( $_SESSION['my_plugin_errors'] ); | |
} |
This file contains 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
if ( ! empty( $errors ) ) { | |
$_SESSION['my_plugin_errors'] = $errors; | |
} |
This file contains 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
if ( !session_id() ) { | |
session_start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment