Jump to content

[SOLVED] Session start troubles


alianated

Recommended Posts

Hello guys,

 

Today i moved to a new server from my home server and i have ran into a problem, keep in mind i never had this problem before so im a bit struck by it, i uploaded my script fully working from my home server to my new server and ill i get now is these two errors constantly, iv fiddled around with it and cant get it to work anyone got any tips ?

 

 

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

 

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

 

Session.php lines 1 through 50

 

<?
include("database.php");
include("mailer.php");
include("form.php");

class Session
{
   var $username;     //Username given on sign-up
   var $userid;       //Random value generated on current login
   var $userlevel;    //The level to which the user pertains
   var $time;         //Time user was last active (page loaded)
   var $logged_in;    //True if user is logged in, false otherwise
   var $userinfo = array();  //The array holding all user info
   var $url;          //The page url current being viewed
   var $referrer;     //Last recorded site page viewed

   function Session(){
      $this->time = time();
      $this->startSession();
   }

   function startSession(){
      global $database;  //The database connection
      session_start();   //Tell PHP to start the session

      $this->logged_in = $this->checkLogin();

      if(!$this->logged_in){
         $this->username = $_SESSION['username'] = GUEST_NAME;
         $this->userlevel = GUEST_LEVEL;
         $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);
      }
      else{
         $database->addActiveUser($this->username, $this->time);
      }
      
      /* Remove inactive visitors from database */
      $database->removeInactiveUsers();
      $database->removeInactiveGuests();
      
      /* Set referrer page */
      if(isset($_SESSION['url'])){
         $this->referrer = $_SESSION['url'];
      }else{
         $this->referrer = "/";
      }

      /* Set current url */
      $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
   }

 

Any ideas are appretiated as im to ill to keep trouling through this for hours,

 

 

Dave.

Link to comment
https://forums.phpfreaks.com/topic/142516-solved-session-start-troubles/
Share on other sites

Just read the errors. They tell you where the output is at that is preventing the session from starting -

 

output started at /home/tinytorr/public_html/include/database.php:287

 

Something at or before line 287 in database.php is being output to the browser. Did you look at line 287 in database.php?

 

If this worked on one system but not another, it is likely that ouptut buffering is turned on in php.ini.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.