Created
December 15, 2012 23:14
-
-
Save samurai/4300376 to your computer and use it in GitHub Desktop.
Session write lock example scripts
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
This is the output per the code executing exactly as it is in this gist. | |
== Output from session_locker.php: == | |
Second file output: | |
Array | |
( | |
[bar] => foo | |
[foo] => bar | |
) | |
sid: q5n46aqf6kc5nladohs81vj217 | |
Array | |
( | |
[bar] => foo | |
[foo] => bar | |
[stuff] => things | |
[otest] => overwitten! | |
) | |
Main file output: | |
Array | |
( | |
[bar] => foo | |
[foo] => bar | |
[otest] => testing | |
) | |
== Output from session_viewer.php: == | |
Array | |
( | |
[bar] => foo | |
[foo] => bar | |
[stuff] => things | |
[otest] => overwitten! | |
) |
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
<?php | |
session_start(); | |
$_SESSION['bar'] = 'foo'; | |
$_SESSION['foo'] = 'bar'; | |
session_write_close(); | |
$_SESSION['otest'] = 'testing?'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, 'http://localhost/session_user.php?id='.session_id()); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); | |
$head = curl_exec($ch); | |
echo "Session_user.php output: <br/><br/>\n\n<pre>"; | |
echo $head; | |
echo "</pre>\n\n<br/><br>Session_locker.php output (after session_user.php was run): <br/><br/>\n\n<pre>"; | |
print_r($_SESSION); | |
echo "</pre>"; | |
?> |
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
<?php | |
session_id($_GET['id']); | |
session_start(); | |
print_r($_SESSION) | |
$_SESSION['stuff'] = 'things'; | |
$_SESSION['otest'] = 'overwitten!'; | |
echo "sid: " . $_GET['id'] . "<br> \n";; | |
print_r($_SESSION); | |
?> |
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
<?php | |
session_start(); | |
echo "<pre>"; | |
print_r($_SESSION); | |
echo "</pre>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment