Created
November 17, 2013 17:58
-
-
Save Danack/7516111 to your computer and use it in GitHub Desktop.
Example of session behaviour. Default PHP locks the session object so that only one process can modify it at once, i.e. the numbers in the two frames will always be different. In APCu PS they can be duplicated.
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 "This is frame 1 with ".ini_get("session.save_handler")." handler <br/>"; | |
if (isset($_SESSION['foo']) == false) { | |
sleep(2); | |
$_SESSION['foo'] = 0; | |
} | |
for($x=0; $x<10 ; $x++) { | |
$_SESSION['foo'] += 1; | |
echo "Foo is ".$_SESSION['foo']."<br/>"; | |
usleep(100000); | |
} |
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 "This is frame 2 with ".ini_get("session.save_handler")." handler <br/>"; | |
if (isset($_SESSION['foo']) == false) { | |
sleep(2); | |
$_SESSION['foo'] = 0; | |
} | |
for($x=0; $x<10 ; $x++) { | |
$_SESSION['foo'] += 1; | |
echo "Foo is ".$_SESSION['foo']."<br/>"; | |
usleep(100000); | |
} |
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
<html> | |
<body> | |
<iframe src='frame1.php' width='200px' height='400px'></iframe> | |
<iframe src='frame2.php' width='200px' height='400px' ></iframe> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment