PHP y sesiones
- ScottG
- Proficient


- Registrado: Jul 06, 2010
- Mensajes: 263
- Status: Offline
OK así que esto no es un error o problema su más de una investigación sobre el pensamiento de otro pueblos. Desde la última edición tuve me causó, así varios días de pesado pensó, ensayo y error y la frustración. Im a partir a repensar cómo Im que va a manejar sesiones.
En el pasado, tengo un archivo que se incluye en cada página de mis proyectos de php llamada initialize.php el papel único de este archivo es configurar la sesión @session_start(); y las clases que se necesitan a través del proyecto como la clase de base de datos.
Ese archivo parece
Un poco de resumen con mi última edición que tuve fue con ImageMagick(IM) ( programación-Foro/imagemagick-y-windows-t108116.html para aquellos que quieren conocer los detalles), pero para decirlo simplemente yo perseguido por un problema y la llamada a IM hecho causaba el tema a pasar por lo que estaba persiguiendo mi cola tratando de encontrar una solución/alternativa para popen() . No fue hasta que arrancaron realmente el script bare bones descubrí la cuestión y eso que tuve sesiones cuando se hizo la llamada a IM si la página se actualiza o se llama otra vez el php script intentaría configurar las sesiones otra vez pero podría no porque las sesiones estaban en uso, resultando en una sesión de trabar esto a su vez le bloqueo IM. Cierre de las sesiones de php antes de la llamada IM y luego les reapertura después de que terminó la llamada resuelven este problema.
Al leer el artículo sobre cerraduras de sesión de PHP, me ha traído a repensar cómo manejar las sesiones. Estoy pensando en crear una clase de sesión para manejar las sesiones. La idea es que el archivo que php escribe información de sesión para siempre ser cerrado a menos que necesite agregar o cambiar las sesiones. Una vez que las sesiones han sido configuración pueden cerrarse y usted todavía será capaz de acceder a la $_SESSION variable.
Tome la siguiente prueba
S1.php este archivo configura una variable de sesión personalizado
S2.php esto representa archivo no era un mal intento desde la sesión continuó dando por resultado ninguna información de sesión
S3.php este archivo inicia/continúa la sesión y luego inmediatamente se cierra el archivo de sesión que nos da acceso a la $_SESSION variable.
Así que esto es la idea básica detrás de mi clase de sesión. Cuando se llama al constructor se inicia y se cierra la sesión inmediatamente que le da el $_SESSION variable. algo importante a destacar es que eres no capaces de fijar cualquier otras sesiones a menos que iniciar la sesión de nuevo. Vea el ejemplo abajo
Por lo que la clase estaría haciendo también será capaz de añadir y cambiar información de sesión así tan en vez de hacer $_SESSION ["índice"] = "content"; haces algo como $sess -> modificar ("índice", "contenido"); .
¿Sus pensamientos o dudas? ¿Qué opinas de este enfoque a las sesiones? Puesto que se trata de una clase muy simple, muy probablemente se completará antes de que nadie lee este post lol.
En el pasado, tengo un archivo que se incluye en cada página de mis proyectos de php llamada initialize.php el papel único de este archivo es configurar la sesión @session_start(); y las clases que se necesitan a través del proyecto como la clase de base de datos.
Ese archivo parece
PHP Código: [ 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 poco de resumen con mi última edición que tuve fue con ImageMagick(IM) ( programación-Foro/imagemagick-y-windows-t108116.html para aquellos que quieren conocer los detalles), pero para decirlo simplemente yo perseguido por un problema y la llamada a IM hecho causaba el tema a pasar por lo que estaba persiguiendo mi cola tratando de encontrar una solución/alternativa para popen() . No fue hasta que arrancaron realmente el script bare bones descubrí la cuestión y eso que tuve sesiones cuando se hizo la llamada a IM si la página se actualiza o se llama otra vez el php script intentaría configurar las sesiones otra vez pero podría no porque las sesiones estaban en uso, resultando en una sesión de trabar esto a su vez le bloqueo IM. Cierre de las sesiones de php antes de la llamada IM y luego les reapertura después de que terminó la llamada resuelven este problema.
Al leer el artículo sobre cerraduras de sesión de PHP, me ha traído a repensar cómo manejar las sesiones. Estoy pensando en crear una clase de sesión para manejar las sesiones. La idea es que el archivo que php escribe información de sesión para siempre ser cerrado a menos que necesite agregar o cambiar las sesiones. Una vez que las sesiones han sido configuración pueden cerrarse y usted todavía será capaz de acceder a la $_SESSION variable.
Tome la siguiente prueba
S1.php este archivo configura una variable de sesión personalizado
PHP Código: [ 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 esto representa archivo no era un mal intento desde la sesión continuó dando por resultado ninguna información de sesión
PHP Código: [ 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 este archivo inicia/continúa la sesión y luego inmediatamente se cierra el archivo de sesión que nos da acceso a la $_SESSION variable.
PHP Código: [ 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
Así que esto es la idea básica detrás de mi clase de sesión. Cuando se llama al constructor se inicia y se cierra la sesión inmediatamente que le da el $_SESSION variable. algo importante a destacar es que eres no capaces de fijar cualquier otras sesiones a menos que iniciar la sesión de nuevo. Vea el ejemplo abajo
PHP Código: [ 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
Por lo que la clase estaría haciendo también será capaz de añadir y cambiar información de sesión así tan en vez de hacer $_SESSION ["índice"] = "content"; haces algo como $sess -> modificar ("índice", "contenido"); .
¿Sus pensamientos o dudas? ¿Qué opinas de este enfoque a las sesiones? Puesto que se trata de una clase muy simple, muy probablemente se completará antes de que nadie lee este post lol.
- Anonymous
- Bot


- Registrado: 25 Feb 2008
- Mensajes: ?
- Loc: Ozzuland
- Status: Online
Marzo 6th, 2013, 9:52 am
- ScottG
- Proficient


- Registrado: Jul 06, 2010
- Mensajes: 263
- Status: Offline
- Bigwebmaster
- Site Admin


- Registrado: Dic 20, 2002
- Mensajes: 8925
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
¿Ha considerado totalmente desguace usando PHPs sesión básica gestor y escribiendo su propia para que usted puede adaptarlo a su exacto necesita y evitar las trampas que esto parece estar causando?
Ozzu Hosting - Want your website on a fast server like Ozzu?
- ScottG
- Proficient


- Registrado: Jul 06, 2010
- Mensajes: 263
- Status: Offline
Tengo pensado hacerlo, pero entonces habría mucho más procesamiento en base de datos o archivos físicos para administrar. Más de mis problemas han sido resueltos por el cierre de la sesión cuando no esté en uso, que por el enlace en el otro post confirmó la cuestión.
Aquí le damos la clase que hace para dirigir la sesión y algunos usos
clase de sesión
prueba 1
prueba 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>
prueba 3
prueba 4
Aquí le damos la clase que hace para dirigir la sesión y algunos usos
clase de sesión
PHP Código: [ 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;
- }
- }
- ?>
prueba 1
PHP Código: [ 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>
prueba 2
PHP Código: [ 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>
prueba 3
PHP Código: [ 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>
prueba 4
PHP Código: [ 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
Página 1 de 1
Para responder a este tema que necesita para ingresar o registrarse. Es gratis.
Publicar Información
- Total de mensajes en este tema: 4 mensajes
- Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 239 invitados
- No puede abrir nuevos temas en este Foro
- No puede responder a temas en este Foro
- No puede editar sus mensajes en este Foro
- No puede borrar sus mensajes en este Foro
- No puede enviar adjuntos en este Foro
