PHP et Sessions
- ScottG
- Proficient


- Inscription: Juil 06, 2010
- Messages: 260
- Status: Online
Ok donc ce n'est pas une erreur ou une question sa a plus d'une enquête sur les autres pensées des peuples. Depuis le dernier numéro, j'ai eu qui m'a amené, ainsi plusieurs jours de forte pensée, de tâtonnements et frustration. Im commence à repenser comment Im va gérer les sessions.
Dans le passé, j'ai un fichier qui est inclu dans toutes les pages de mes projets php appelé initialize.php le rôle unique de ce fichier est de configurer la session @session_start() ; et toutes les classes qui sont nécessaires par le biais du projet comme la classe de base de données.
Ce fichier ressemble à
Un peu d'aperçu avec ma dernière question, j'ai eu était avec ImageMagick(IM) ( programmation-forum/imagemagick-et-windows-t108116.html pour ceux qui veulent connaître les détails), mais pour dire les choses simplement j'ai chassé vers le bas un problème et l'appel à IM était en effet l'origine du problème se produise alors que je courais à ma queue en essayant de trouver une fix/alternative pour popen() . Il n'était pas jusqu'à ce que j'ai vraiment déchiré le script à bare bones, j'ai découvert la question et qu'étant que depuis que j'ai eu des séances quand l'appel à IM a été effectuée si la page est actualisée ou appelée à nouveau le php script serait essayer de configurer les sessions à nouveau, mais il pourrait pas parce que les sessions ont été utilisées, résultant en une session verrouiller ceci à son tour aurait blocage IM. Fermer les sessions php avant l'appel IM et ensuite leur réouverture après que l'appel était terminé résolu ce problème.
En lisant l'article ci-dessus sur PHP Session se verrouille, m'a amené à repenser comment traiter les séances. Je pense à la création d'une classe de Session pour gérer les sessions. L'idée étant que le fichier que php écrit info session à sera toujours fermé sauf si vous avez besoin ajouter ou modifier des séances. Une fois que les sessions ont été mis en place qu'ils peuvent être fermés, et vous serez toujours en mesure d'accéder à la $_SESSION variable.
Faites le test suivant
S1.php ce fichier définit une variable de session personnalisé
S2.php ce fichier représente une tentative mal depuis la session n'a pas étée continué résultant dans aucune info Session
S3.php ce fichier démarre/continue la session et puis se ferme immédiatement le fichier de session qui nous donne accès à la $_SESSION variable.
C'est donc l'idée de base derrière ma classe session. Lorsque le constructeur est appelé il commence et se termine la session immédiatement en vous donnant la $_SESSION variable. une chose importante à noter est que vous êtes pas en mesure de définir les autres sessions sauf si vous démarrez la session à nouveau. Voir l'exemple ci-dessous
La classe j'ai rendrait aussi pourrez donc ajouter et modifier les infos de session ainsi donc au lieu de faire $_SESSION ["index"] = "content" ; vous devriez faire quelque chose comme $sess -> Modifier ("index", "contenu"); .
Des idées ou des préoccupations ? Que pensez-vous de cette approche aux Sessions ? Puisqu'il s'agit d'une classe très simple, qu'il sera probablement achevée avant que quiconque lit ce post lol.
Dans le passé, j'ai un fichier qui est inclu dans toutes les pages de mes projets php appelé initialize.php le rôle unique de ce fichier est de configurer la session @session_start() ; et toutes les classes qui sont nécessaires par le biais du projet comme la classe de base de données.
Ce fichier ressemble à
PHP Code: [ Select ]
<?php
/**
* The initialize class starts all of the main classes and
* sets the site up.
*
* @Author William Gaines <sgscott87@gmail.com>
* @Copyright 2013-2014 indefinite Designs.
*
*/
/***********************************/
/* Start Session */
/***********************************/
// Start/Continue a session
@session_start();
/***********************************/
/* Error Reporting */
/***********************************/
// We want to see our errors
ini_set('display_errors', '1');
// Report all except notices
error_reporting(E_ALL ^ E_NOTICE);
/***********************************/
/* Includes and Objects */
/***********************************/
// Include the config
require_once('config.php');
// General Functions
require_once('general.php');
// Start our error class
require_once('class.error.php');
$err = new Error();
// Database Authentication File
require_once('dbauth.php');
// Start our database object instance (singleton)
require_once('class.db_connect.php');
$db = DBConnection::instance();
?>
/**
* The initialize class starts all of the main classes and
* sets the site up.
*
* @Author William Gaines <sgscott87@gmail.com>
* @Copyright 2013-2014 indefinite Designs.
*
*/
/***********************************/
/* Start Session */
/***********************************/
// Start/Continue a session
@session_start();
/***********************************/
/* Error Reporting */
/***********************************/
// We want to see our errors
ini_set('display_errors', '1');
// Report all except notices
error_reporting(E_ALL ^ E_NOTICE);
/***********************************/
/* Includes and Objects */
/***********************************/
// Include the config
require_once('config.php');
// General Functions
require_once('general.php');
// Start our error class
require_once('class.error.php');
$err = new Error();
// Database Authentication File
require_once('dbauth.php');
// Start our database object instance (singleton)
require_once('class.db_connect.php');
$db = DBConnection::instance();
?>
- <?php
- /**
- * The initialize class starts all of the main classes and
- * sets the site up.
- *
- * @Author William Gaines <sgscott87@gmail.com>
- * @Copyright 2013-2014 indefinite Designs.
- *
- */
- /***********************************/
- /* Start Session */
- /***********************************/
- // Start/Continue a session
- @session_start();
- /***********************************/
- /* Error Reporting */
- /***********************************/
- // We want to see our errors
- ini_set('display_errors', '1');
- // Report all except notices
- error_reporting(E_ALL ^ E_NOTICE);
- /***********************************/
- /* Includes and Objects */
- /***********************************/
- // Include the config
- require_once('config.php');
- // General Functions
- require_once('general.php');
- // Start our error class
- require_once('class.error.php');
- $err = new Error();
- // Database Authentication File
- require_once('dbauth.php');
- // Start our database object instance (singleton)
- require_once('class.db_connect.php');
- $db = DBConnection::instance();
- ?>
Un peu d'aperçu avec ma dernière question, j'ai eu était avec ImageMagick(IM) ( programmation-forum/imagemagick-et-windows-t108116.html pour ceux qui veulent connaître les détails), mais pour dire les choses simplement j'ai chassé vers le bas un problème et l'appel à IM était en effet l'origine du problème se produise alors que je courais à ma queue en essayant de trouver une fix/alternative pour popen() . Il n'était pas jusqu'à ce que j'ai vraiment déchiré le script à bare bones, j'ai découvert la question et qu'étant que depuis que j'ai eu des séances quand l'appel à IM a été effectuée si la page est actualisée ou appelée à nouveau le php script serait essayer de configurer les sessions à nouveau, mais il pourrait pas parce que les sessions ont été utilisées, résultant en une session verrouiller ceci à son tour aurait blocage IM. Fermer les sessions php avant l'appel IM et ensuite leur réouverture après que l'appel était terminé résolu ce problème.
En lisant l'article ci-dessus sur PHP Session se verrouille, m'a amené à repenser comment traiter les séances. Je pense à la création d'une classe de Session pour gérer les sessions. L'idée étant que le fichier que php écrit info session à sera toujours fermé sauf si vous avez besoin ajouter ou modifier des séances. Une fois que les sessions ont été mis en place qu'ils peuvent être fermés, et vous serez toujours en mesure d'accéder à la $_SESSION variable.
Faites le test suivant
S1.php ce fichier définit une variable de session personnalisé
PHP Code: [ Select ]
<?php
@session_start();
$_SESSION['my_session'] = 'Yay! It works';
session_write_close();
?>
<br />
<a href="s2.php">Next</a>
@session_start();
$_SESSION['my_session'] = 'Yay! It works';
session_write_close();
?>
<br />
<a href="s2.php">Next</a>
- <?php
- @session_start();
- $_SESSION['my_session'] = 'Yay! It works';
- session_write_close();
- ?>
- <br />
- <a href="s2.php">Next</a>
S2.php ce fichier représente une tentative mal depuis la session n'a pas étée continué résultant dans aucune info Session
PHP Code: [ Select ]
<?php
echo (!empty($_SESSION['my_session'])) ? $_SESSION['my_session'] : 'Boo! It failed! You Suck Sessions!';
?>
<br />
<a href="s3.php">Next</a>
echo (!empty($_SESSION['my_session'])) ? $_SESSION['my_session'] : 'Boo! It failed! You Suck Sessions!';
?>
<br />
<a href="s3.php">Next</a>
- <?php
- echo (!empty($_SESSION['my_session'])) ? $_SESSION['my_session'] : 'Boo! It failed! You Suck Sessions!';
- ?>
- <br />
- <a href="s3.php">Next</a>
S3.php ce fichier démarre/continue la session et puis se ferme immédiatement le fichier de session qui nous donne accès à la $_SESSION variable.
PHP Code: [ Select ]
<?php
@session_start(); session_write_close();
echo (!empty($_SESSION['my_session'])) ? $_SESSION['my_session'] : 'Boo! It failed! You Suck Sessions!';
?>
<br />
FIN
@session_start(); session_write_close();
echo (!empty($_SESSION['my_session'])) ? $_SESSION['my_session'] : 'Boo! It failed! You Suck Sessions!';
?>
<br />
FIN
- <?php
- @session_start(); session_write_close();
- echo (!empty($_SESSION['my_session'])) ? $_SESSION['my_session'] : 'Boo! It failed! You Suck Sessions!';
- ?>
- <br />
- FIN
C'est donc l'idée de base derrière ma classe session. Lorsque le constructeur est appelé il commence et se termine la session immédiatement en vous donnant la $_SESSION variable. une chose importante à noter est que vous êtes pas en mesure de définir les autres sessions sauf si vous démarrez la session à nouveau. Voir l'exemple ci-dessous
PHP Code: [ Select ]
<?php
@session_start();
$_SESSION['my_session'] = 'Yay! It works';
session_write_close();
$_SESSION['bad_session'] = 'This will not work!';
@session_start();
$_SESSION['good_session'] = 'Yay! Another good session!';
session_write_close();
?>
<pre>
<?php
var_dump($_SESSION);
?>
</pre>
<br />
FIN
@session_start();
$_SESSION['my_session'] = 'Yay! It works';
session_write_close();
$_SESSION['bad_session'] = 'This will not work!';
@session_start();
$_SESSION['good_session'] = 'Yay! Another good session!';
session_write_close();
?>
<pre>
<?php
var_dump($_SESSION);
?>
</pre>
<br />
FIN
- <?php
- @session_start();
- $_SESSION['my_session'] = 'Yay! It works';
- session_write_close();
- $_SESSION['bad_session'] = 'This will not work!';
- @session_start();
- $_SESSION['good_session'] = 'Yay! Another good session!';
- session_write_close();
- ?>
- <pre>
- <?php
- var_dump($_SESSION);
- ?>
- </pre>
- <br />
- FIN
La classe j'ai rendrait aussi pourrez donc ajouter et modifier les infos de session ainsi donc au lieu de faire $_SESSION ["index"] = "content" ; vous devriez faire quelque chose comme $sess -> Modifier ("index", "contenu"); .
Des idées ou des préoccupations ? Que pensez-vous de cette approche aux Sessions ? Puisqu'il s'agit d'une classe très simple, qu'il sera probablement achevée avant que quiconque lit ce post lol.
- Anonymous
- Bot


- Inscription: 25 Feb 2008
- Messages: ?
- Loc: Ozzuland
- Status: Online
Mars 6th, 2013, 9:52 am
- ScottG
- Proficient


- Inscription: Juil 06, 2010
- Messages: 260
- Status: Online
- Bigwebmaster
- Site Admin


- Inscription: Déc 20, 2002
- Messages: 8922
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
Avez-vous considéré complètement mise au rebut à l'aide du gestionnaire de sessions de base de PHP et l'écrit votre propre afin que vous pouvez adapter à votre exact besoin et éviter les écueils que cela semble vous causer ?
Ozzu Hosting - Want your website on a fast server like Ozzu?
- ScottG
- Proficient


- Inscription: Juil 06, 2010
- Messages: 260
- Status: Online
J'ai pensé à faire ça, mais il n'y aurait beaucoup plus de traitement va sur base de données ou des fichiers physiques à gérer. Plus mes problèmes ont été résolus en fermant la session quand pas en service qui, par le lien dans l'autre poteau, a confirmé le problème.
Voici la classe que j'ai faite pour gérer la session et à certains usages
classe session
test 1
test 2
<?php
require_once('cms/classes/class.session.php');
$session = new Session();
?>
<pre>
<?php
var_dump($_SESSION);
?>
</pre>
<?php
echo 'What about removing Sessions?';
$session->kill('second_test');
$session->kill(array('forth_test', 'fith_test'));
?>
<pre>
<?php
var_dump($_SESSION);
?>
</pre>
<br />
<a href="s2.php">Refresh</a> <a href="s3.php">Next</a>
test 3
test 4
Voici la classe que j'ai faite pour gérer la session et à certains usages
classe session
PHP Code: [ Select ]
<?php
/**
* This file is the user class. It is used to add edit
* delete login or anything else that involes the user.
*
* @Author William Gaines <sgscott87@gmail.com>
* @Copyright 2013-2015
*
*/
/***********************************/
/* Initialize */
/***********************************/
class Session {
// Start up the Session
function __construct() {
// Setup the session
$this->start();
$this->stop();
}
// This function will start the session
public function start() {
// Start/Continue the session
(headers_sent()) ? @session_start() : session_start();
}
// This function will stop the session
public function stop() {
// Write the close of the seesion file and unlock it
session_write_close();
}
/**
* Adds/Edits Session info
*
* @param string/array $index This variable can be used as a string for the index in the session variable or as an associative array for the index and content
* @param string/boolean $content This is the content that will be added to the index in the session. This will be false if the $index is an array.
* @return boolean
*/
public function modify($index, $content = false) {
// Start Session
$this->start();
// Check to see if the $index is an array
if(is_array($index)) {
// Loop the index array
foreach($index as $key => $value) {
// Add to the Session
$_SESSION[$key] = $value;
}
} else {
// Add to the Session
$_SESSION[$index] = $content;
}
// Stop Session
$this->stop();
// Kick out
return true;
}
/**
* Removes session info
*
* @param string/array $index This variable can be used as a string for the index in the session variable or as an array of indexs
* @return boolean
*/
public function kill($index) {
// Start Session
$this->start();
// Check to see if the $index is an array
if(is_array($index)) {
// Loop the index array
foreach($index as $key => $value) {
// Add to the Session
unset($_SESSION[$value]);
}
} else {
// Add to the Session
unset($_SESSION[$index]);
}
// Stop Session
$this->stop();
// Kick out
return true;
}
/**
* Removes ALL session info and reset everything
*
* Note: This will cause an error if there is already output on the page before calling the destroy
* @return boolean
*/
public function destroy() {
// Kill the variables
$this->kill($_SESSION);
// Start Session
$this->start();
// Unset the session
session_unset();
// Check for headers sent and spit out a better error if they are. This is so that there is only one error that better describes what is going on
// this will suppress the errors if the headers are sent and spit out nice warnings
if(headers_sent($filename, $linenum)) {
// Clear cookies
@setcookie(session_name(),'',0,'/');
// Reset the session id
@session_regenerate_id();
// Spit out error
echo "<br /><strong>Warning:</strong> Your session may not be destroyed. You are receiving this warning due to the headers already being sent. This could occur due to output already on the page before the destroy function was called in <strong>$filename</strong> on line <strong>$linenum</strong><br />\n";
} else {
// Clear cookies
setcookie(session_name(),'',0,'/');
// Reset the session id
session_regenerate_id();
}
// Stop Session
$this->stop();
// Kick out
return true;
}
}
?>
/**
* This file is the user class. It is used to add edit
* delete login or anything else that involes the user.
*
* @Author William Gaines <sgscott87@gmail.com>
* @Copyright 2013-2015
*
*/
/***********************************/
/* Initialize */
/***********************************/
class Session {
// Start up the Session
function __construct() {
// Setup the session
$this->start();
$this->stop();
}
// This function will start the session
public function start() {
// Start/Continue the session
(headers_sent()) ? @session_start() : session_start();
}
// This function will stop the session
public function stop() {
// Write the close of the seesion file and unlock it
session_write_close();
}
/**
* Adds/Edits Session info
*
* @param string/array $index This variable can be used as a string for the index in the session variable or as an associative array for the index and content
* @param string/boolean $content This is the content that will be added to the index in the session. This will be false if the $index is an array.
* @return boolean
*/
public function modify($index, $content = false) {
// Start Session
$this->start();
// Check to see if the $index is an array
if(is_array($index)) {
// Loop the index array
foreach($index as $key => $value) {
// Add to the Session
$_SESSION[$key] = $value;
}
} else {
// Add to the Session
$_SESSION[$index] = $content;
}
// Stop Session
$this->stop();
// Kick out
return true;
}
/**
* Removes session info
*
* @param string/array $index This variable can be used as a string for the index in the session variable or as an array of indexs
* @return boolean
*/
public function kill($index) {
// Start Session
$this->start();
// Check to see if the $index is an array
if(is_array($index)) {
// Loop the index array
foreach($index as $key => $value) {
// Add to the Session
unset($_SESSION[$value]);
}
} else {
// Add to the Session
unset($_SESSION[$index]);
}
// Stop Session
$this->stop();
// Kick out
return true;
}
/**
* Removes ALL session info and reset everything
*
* Note: This will cause an error if there is already output on the page before calling the destroy
* @return boolean
*/
public function destroy() {
// Kill the variables
$this->kill($_SESSION);
// Start Session
$this->start();
// Unset the session
session_unset();
// Check for headers sent and spit out a better error if they are. This is so that there is only one error that better describes what is going on
// this will suppress the errors if the headers are sent and spit out nice warnings
if(headers_sent($filename, $linenum)) {
// Clear cookies
@setcookie(session_name(),'',0,'/');
// Reset the session id
@session_regenerate_id();
// Spit out error
echo "<br /><strong>Warning:</strong> Your session may not be destroyed. You are receiving this warning due to the headers already being sent. This could occur due to output already on the page before the destroy function was called in <strong>$filename</strong> on line <strong>$linenum</strong><br />\n";
} else {
// Clear cookies
setcookie(session_name(),'',0,'/');
// Reset the session id
session_regenerate_id();
}
// Stop Session
$this->stop();
// Kick out
return true;
}
}
?>
- <?php
- /**
- * This file is the user class. It is used to add edit
- * delete login or anything else that involes the user.
- *
- * @Author William Gaines <sgscott87@gmail.com>
- * @Copyright 2013-2015
- *
- */
- /***********************************/
- /* Initialize */
- /***********************************/
- class Session {
- // Start up the Session
- function __construct() {
- // Setup the session
- $this->start();
- $this->stop();
- }
- // This function will start the session
- public function start() {
- // Start/Continue the session
- (headers_sent()) ? @session_start() : session_start();
- }
- // This function will stop the session
- public function stop() {
- // Write the close of the seesion file and unlock it
- session_write_close();
- }
- /**
- * Adds/Edits Session info
- *
- * @param string/array $index This variable can be used as a string for the index in the session variable or as an associative array for the index and content
- * @param string/boolean $content This is the content that will be added to the index in the session. This will be false if the $index is an array.
- * @return boolean
- */
- public function modify($index, $content = false) {
- // Start Session
- $this->start();
- // Check to see if the $index is an array
- if(is_array($index)) {
- // Loop the index array
- foreach($index as $key => $value) {
- // Add to the Session
- $_SESSION[$key] = $value;
- }
- } else {
- // Add to the Session
- $_SESSION[$index] = $content;
- }
- // Stop Session
- $this->stop();
- // Kick out
- return true;
- }
- /**
- * Removes session info
- *
- * @param string/array $index This variable can be used as a string for the index in the session variable or as an array of indexs
- * @return boolean
- */
- public function kill($index) {
- // Start Session
- $this->start();
- // Check to see if the $index is an array
- if(is_array($index)) {
- // Loop the index array
- foreach($index as $key => $value) {
- // Add to the Session
- unset($_SESSION[$value]);
- }
- } else {
- // Add to the Session
- unset($_SESSION[$index]);
- }
- // Stop Session
- $this->stop();
- // Kick out
- return true;
- }
- /**
- * Removes ALL session info and reset everything
- *
- * Note: This will cause an error if there is already output on the page before calling the destroy
- * @return boolean
- */
- public function destroy() {
- // Kill the variables
- $this->kill($_SESSION);
- // Start Session
- $this->start();
- // Unset the session
- session_unset();
- // Check for headers sent and spit out a better error if they are. This is so that there is only one error that better describes what is going on
- // this will suppress the errors if the headers are sent and spit out nice warnings
- if(headers_sent($filename, $linenum)) {
- // Clear cookies
- @setcookie(session_name(),'',0,'/');
- // Reset the session id
- @session_regenerate_id();
- // Spit out error
- echo "<br /><strong>Warning:</strong> Your session may not be destroyed. You are receiving this warning due to the headers already being sent. This could occur due to output already on the page before the destroy function was called in <strong>$filename</strong> on line <strong>$linenum</strong><br />\n";
- } else {
- // Clear cookies
- setcookie(session_name(),'',0,'/');
- // Reset the session id
- session_regenerate_id();
- }
- // Stop Session
- $this->stop();
- // Kick out
- return true;
- }
- }
- ?>
test 1
PHP Code: [ Select ]
<?php
require_once('cms/classes/class.session.php');
$session = new Session();
$session->modify('first_test', 'Yay! It works');
// Make an array for sessions
$test_array = array(
"first_test" => '1 I think you\'ve won!',
"second_test" => '2 you belong in a zoo!',
"third_test" => '3 your just like me!',
"forth_test" => '4 get off the floor!',
"fith_test" => '5 ... Umm your starting to jive?',
"sixth_test" => '6 pickup those sticks!'
);
$session->modify($test_array);
?>
<pre>
<?php
var_dump($_SESSION);
?>
</pre>
<br />
<a href="s2.php">Next</a>
require_once('cms/classes/class.session.php');
$session = new Session();
$session->modify('first_test', 'Yay! It works');
// Make an array for sessions
$test_array = array(
"first_test" => '1 I think you\'ve won!',
"second_test" => '2 you belong in a zoo!',
"third_test" => '3 your just like me!',
"forth_test" => '4 get off the floor!',
"fith_test" => '5 ... Umm your starting to jive?',
"sixth_test" => '6 pickup those sticks!'
);
$session->modify($test_array);
?>
<pre>
<?php
var_dump($_SESSION);
?>
</pre>
<br />
<a href="s2.php">Next</a>
- <?php
- require_once('cms/classes/class.session.php');
- $session = new Session();
- $session->modify('first_test', 'Yay! It works');
- // Make an array for sessions
- $test_array = array(
- "first_test" => '1 I think you\'ve won!',
- "second_test" => '2 you belong in a zoo!',
- "third_test" => '3 your just like me!',
- "forth_test" => '4 get off the floor!',
- "fith_test" => '5 ... Umm your starting to jive?',
- "sixth_test" => '6 pickup those sticks!'
- );
- $session->modify($test_array);
- ?>
- <pre>
- <?php
- var_dump($_SESSION);
- ?>
- </pre>
- <br />
- <a href="s2.php">Next</a>
test 2
PHP Code: [ Select ]
<?php
require_once('cms/classes/class.session.php');
$session = new Session();
?>
<pre>
<?php
var_dump($_SESSION);
?>
</pre>
<?php
echo 'What about removing Sessions?';
$session->kill('second_test');
$session->kill(array('forth_test', 'fith_test'));
?>
<pre>
<?php
var_dump($_SESSION);
?>
</pre>
<br />
<a href="s2.php">Refresh</a> <a href="s3.php">Next</a>
- <?php
- require_once('cms/classes/class.session.php');
- $session = new Session();
- ?>
- <pre>
- <?php
- var_dump($_SESSION);
- ?>
- </pre>
- <?php
- echo 'What about removing Sessions?';
- $session->kill('second_test');
- $session->kill(array('forth_test', 'fith_test'));
- ?>
- <pre>
- <?php
- var_dump($_SESSION);
- ?>
- </pre>
- <br />
- <a href="s2.php">Refresh</a> <a href="s3.php">Next</a>
test 3
PHP Code: [ Select ]
<?php
require_once('cms/classes/class.session.php');
$session = new Session();
// Please Note that before trying to destroy the sessions you CANNOT have any output before this call.
// This call is to destroy and rest the session info. This would happen mostly on a logout page.
$session->destroy();
echo 'What about Destroying Sessions?';
?>
<pre>
<?php
var_dump($_SESSION);
?>
</pre>
<br />
<a href="s4.php">Next</a>
require_once('cms/classes/class.session.php');
$session = new Session();
// Please Note that before trying to destroy the sessions you CANNOT have any output before this call.
// This call is to destroy and rest the session info. This would happen mostly on a logout page.
$session->destroy();
echo 'What about Destroying Sessions?';
?>
<pre>
<?php
var_dump($_SESSION);
?>
</pre>
<br />
<a href="s4.php">Next</a>
- <?php
- require_once('cms/classes/class.session.php');
- $session = new Session();
- // Please Note that before trying to destroy the sessions you CANNOT have any output before this call.
- // This call is to destroy and rest the session info. This would happen mostly on a logout page.
- $session->destroy();
- echo 'What about Destroying Sessions?';
- ?>
- <pre>
- <?php
- var_dump($_SESSION);
- ?>
- </pre>
- <br />
- <a href="s4.php">Next</a>
test 4
PHP Code: [ Select ]
<?php
require_once('cms/classes/class.session.php');
$session = new Session();
?>
So you need to do something with the sessions that's not in this class?
<br />
<?php
$session->start();
// Do your stuff here
$session->stop();
?>
<br />
<br />
FIN
require_once('cms/classes/class.session.php');
$session = new Session();
?>
So you need to do something with the sessions that's not in this class?
<br />
<?php
$session->start();
// Do your stuff here
$session->stop();
?>
<br />
<br />
FIN
- <?php
- require_once('cms/classes/class.session.php');
- $session = new Session();
- ?>
- So you need to do something with the sessions that's not in this class?
- <br />
- <?php
- $session->start();
- // Do your stuff here
- $session->stop();
- ?>
- <br />
- <br />
- FIN
Page 1 sur 1
Pour répondre à ce sujet, vous devez vous connecter ou vous enregistrer. Il est gratuit.
Afficher de l'information
- Total des messages de ce sujet: 4 messages
- Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 197 invités
- Vous ne pouvez pas poster de nouveaux sujets
- Vous ne pouvez pas répondre aux sujets
- Vous ne pouvez pas éditer vos messages
- Vous ne pouvez pas supprimer vos messages
- Vous ne pouvez pas joindre des fichiers
