Computing.Net > Forums > Web Development > PHP session problem

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

PHP session problem

Reply to Message Icon

Name: ciru3
Date: January 21, 2008 at 10:34:58 Pacific
OS: Windows XP
CPU/Ram: Athlon X2 3600 1GB
Product: ECS
Comment:

When i open the page i get the next message

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/numat/domains/numata.com.ar/public_html/index.php:1) in /home/numat/domains/numata.com.ar/public_html/verific.php on line 3

the firts lines of index are:
<? include("verific.php");
if ($_SESSION["autentificado"] == "YES") {
include("backend/connect.php");
$result = mysql_query("SELECT * FROM users WHERE session_client='$loginUser'");
$reg = mysql_fetch_object($result);
$username_user = $reg->username_user;
$_SESSION["usuario"]=$username_user;
$empresa = $reg->empresa_user;
$name = $reg->nombre_user;
$direccion = $reg->direccion_user;
$telefono = $reg->telefono_user;
$email = $reg->email_user;
$activo = $reg->activado_user;
}
?>


And the first lines of verific are

<?
session_name("loginUser");
session_start();
if ($_SESSION["autentificado"] == "YES") {
$fechaGuardada = $_SESSION["ultimoAcceso"];
$ahora = date("Y-n-j H:i:s");
$tiempo_transcurrido = (strtotime($ahora)-strtotime($fechaGuardada));
if($tiempo_transcurrido >= 600) {
include("logout_user.php");
}else {
$_SESSION["ultimoAcceso"] = $ahora;
}
}
?>

Can anyone tell me what's the problem??



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: January 21, 2008 at 15:09:17 Pacific
Reply:

On line 1 session_name() is attempting to set the session name. But, you don't start the session until line 2. reverse those two lines and it should fix the problem.


<?
session_start();
session_name("loginUser");
if ($_SESSION["autentificado"] == "YES") {
$fechaGuardada = $_SESSION["ultimoAcceso"];
$ahora = date("Y-n-j H:i:s");
$tiempo_transcurrido = (strtotime($ahora)-strtotime($fechaGuardada));
if($tiempo_transcurrido >= 600) {
include("logout_user.php");
}else {
$_SESSION["ultimoAcceso"] = $ahora;
}
}
?>

Michael J


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: PHP session problem

PHP Session Timeout www.computing.net/answers/webdevel/php-session-timeout/3877.html

PHP session related prob www.computing.net/answers/webdevel/php-session-related-prob/3433.html

PHP sessions not working www.computing.net/answers/webdevel/php-sessions-not-working/571.html