Created
March 15, 2010 10:41
-
-
Save dandelionmood/332725 to your computer and use it in GitHub Desktop.
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 | |
// Cette variable contiendra l'identifiant unique de la session | |
$token_session = ''; | |
// Un cookie contenant l'identifiant de session a-t-il été déjà défini ? | |
if( !isset($_COOKIE['__token_session']) ) | |
{ | |
// Génération d'un identifiant unique s'il n'existait pas encore. | |
$token_session = uniqid('session', true); | |
} | |
else | |
{ | |
// On réutilise l'ancien identifiant de session. | |
$token_session = $cookie['__token_session']; | |
} | |
// Dans tous les cas, on prolonge le cookie de 10 minutes avant expiration | |
setcookie("__token_session", $token_session, strtotime('+10 minutes'), '/'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment