Jump to content

Recommended Posts

Please look into this,

 

session_save_path("/some/path/to/dir/");

 

This ("/some/path/to/dir/"), should i leave it this way, or i must specify some path to a directory and if yes, what directory?

 

I hope you understand

 

You need to change the path to somewhere, I would say outside of the document root if you can.

This is 1-3 lines of session.php

 

<?php
session_start();
$afso_name=session_name();
$afso_sid=session_id();
?>

 

The below is 1-8 lines of login.php

 

<?php

session_start();

if (!isset ($_SESSION["admin_id"]))

{
  header ("Location:main.php?login=missing");
}

include("connect.php");

if($log){

$sqllog=mysql_query(" SELECT  * FROM  enter_code WHERE aname='$loginname' ");
?>

 

I put this code in the main file,

ini_set ("display_errors", "1");
error_reporting(E_ALL);

 

This is what it outputted;

Warning: session_start() [function.session-start]: open(/tmp/sess_d90f4557eceb9cdf247d9e5e5301e58f, O_RDWR) failed: Read-only file system (30) in /home/prudccou/public_html/session.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/prudccou/public_html/session.php:2) in /home/prudccou/public_html/session.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/prudccou/public_html/session.php:2) in /home/prudccou/public_html/session.php on line 2

Notice: Undefined index: afso_userid in /home/prudccou/public_html/session.php on line 5

Notice: A session had already been started - ignoring session_start() in /home/prudccou/public_html/login.php on line 3

Warning: Cannot modify header information - headers already sent by (output started at /home/prudccou/public_html/session.php:2) in /home/prudccou/public_html/login.php on line 8

Notice: Undefined variable: log in /home/prudccou/public_html/login.php on line 13

@ R0bb0b

 

I placed session.php in my includes folder in /www directory

 

I believe my code should look like this;

 

ini_set("session.save_path","/public_html/includes/");

 

Also, what is funny about session had already started

 

 

@ R0bb0b

 

I placed session.php in my includes folder in /www directory

 

I believe my code should look like this;

 

ini_set("session.save_path","/public_html/includes/");

 

Also, what is funny about session had already started

 

I'm not exactly sure what the permissions on session files are, but I would assume that you would want to keep them outside of the document root, is that possible?

 

Its funny that the session is already started because if this is the case, it sounds like the issue happens randomly because if failed the first time and apparently succeeded later on.  Are you calling session_save_path() on the very first line of code that runs after your first "<?php" tag?  If not, that's what you want to do.

A) Where in your code are you putting the line to set  session.save_path?

 

B) login.php and session.php are obviously being included by some main file. Post that code as well.

 

C) After the header() redirect in login.php, add a exit(); statement. I suspect this is partly responsible for the original error as that page will continue executing and the browser will request main.php, which I am going to guess contains or includes a file the contains a session_start();

 

@R0bb0b, his error reporting was set to prevent notice messages from being reported and the "Notice: A session had already been started" was occurring all along.

 

This code is a mess. There should only be one session_start() statement at the beginning of the page and the code that R0bb0b has given to set session.save_path must go before that single session_start().

 

I am going to guess that if the header() redirect is not causing the original error that this tangle of include statements/session_starts is what is causing the original error.

Setting the session.save_path is an attempt to work around a tmp folder that might have a problem. However, based on what the code is doing, it is likely the code is causing this and setting the session.save_path to a different folder won't have any effect on the original error.

A) Where in your code are you putting the line to set  session.save_path?

 

B) login.php and session.php are obviously being included by some main file. Post that code as well.

 

C) After the header() redirect in login.php, add a exit(); statement. I suspect this is partly responsible for the original error as that page will continue executing and the browser will request main.php, which I am going to guess contains or includes a file the contains a session_start();

 

@R0bb0b, his error reporting was set to prevent notice messages from being reported and the "Notice: A session had already been started" was occurring all along.

 

This code is a mess. There should only be one session_start() statement at the beginning of the page and the code that R0bb0b has given to set session.save_path must go before that single session_start().

 

I am going to guess that if the header() redirect is not causing the original error that this tangle of include statements/session_starts is what is causing the original error.

 

A) I am putting session.save_path in session.php

B) this is the main file. main.php

 

<?
include("session.php");
include("connect.php");
include("admin/includes/en.php");
$return="Access Code";

if($login=="wrong"){
$return="Access code wrong";
}

else if($login=="missing"){
$return="Access code missing";
}
require("index_login.php");

?>

 

C) I have added exit after redirecting.

 

Take a look at the full code for login.php

 

<?php

session_start();

if (!isset ($_SESSION["admin_id"]))

{
  header ("Location:main.php?login=missing");
}

include("connect.php");

if($log){

$sqllog=mysql_query(" SELECT  * FROM  enter_code WHERE aname='$loginname' ");

if($sqllog){
$row=mysql_fetch_array($sqllog);
$rowid=$row["id"];
} 

$num=mysql_num_rows($sqllog);
if($num > 0){

$_SESSION["admin_id"]=$row["adminid"];
   header ("Location: index.php");
}
else
{
  header ("Location: main.php?login=wrong");
}

}
?>

C) I have added exit after redirecting.
Except, I don't see any exit; statements in the code you posted for login.php.

 

Every header ("Location:some_url"); must have an exit; statement after it to prevent the remainder of the code from being executed. Your login code could be sending up to two header() redirects, both of which will be requested by the browser.

I posted the old long.php. I have added the exit(); and this is the error am getting.

 

Warning: session_start() [function.session-start]: open(/tmp/sess_86fe007aecc23577c9629d5a4e231cde, O_RDWR) failed: Read-only file system (30) in /home/prudccou/public_html/session.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/prudccou/public_html/session.php:2) in /home/prudccou/public_html/session.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/prudccou/public_html/session.php:2) in /home/prudccou/public_html/session.php on line 2

Notice: Undefined index: afso_userid in /home/prudccou/public_html/session.php on line 5

Parse error: syntax error, unexpected ':' in /home/prudccou/public_html/login.php on line 32

Warning: Unknown(): open(/tmp/sess_86fe007aecc23577c9629d5a4e231cde, O_RDWR) failed: Read-only file system (30) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

session_name(), session_id() before session_start().

 

Am hearing that for the first time :X

 

These should not be necessary.  At this point I would create one test file, start a session and play with the session variables.  This will allow you to determine if there is an issue with the server or your code.

session_name(), session_id() before session_start().

 

Am hearing that for the first time :X

 

According to the php manual:

 

 

Description

string session_name ([ string $name ] )

 

session_name() returns the name of the current session.

 

The session name is reset to the default value stored in session.name at request startup time. Thus, you need to call session_name() for every request (and before session_start() or session_register() are called).

Lol, no you don't need to call session_name or session_id, you just need session start.

 

But if he can post his full code with the errors he may get a faster/better answer.

 

I know you don't need to call session_name or session_id, but he is in his code.

 

I am very interested to see what the fix is in the end.

I managed to fix the problem. A developer friend of mine said its a random error from the host. That there is nothing to do. Actually, i did nothing and all errors dissappeared.

 

Thanks guys for ur Help.

 

PFMaBiSmAd and Blade280891, Kudos to you guys.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.