[Added Source] How to solve this session bug?

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • [Added Source] How to solve this session bug?

      Hi, I've just installed 2Moons v1.3 RC5.
      And the server is keep showing me this PHP bug.


      Warning: ini_set() [function.ini-set]: A session is active. You cannot change the session module's ini settings at this time in C:\web\public_html\2moons\common.php on line 49

      Warning: ini_set() [function.ini-set]: A session is active. You cannot change the session module's ini settings at this time in C:\web\public_html\2moons\common.php on line 51


      What should I do to solve this bug?

      I'm using PHP 5.3, so I guess PHP version is not a problem..

      This is 1.3 commom.php

      PHP Source Code: common.php

      1. <?php
      2. /**
      3. * 2Moons
      4. * Copyright (C) 2011 Slaver
      5. *
      6. * This program is free software: you can redistribute it and/or modify
      7. * it under the terms of the GNU General Public License as published by
      8. * the Free Software Foundation, either version 3 of the License, or
      9. * (at your option) any later version.
      10. *
      11. * This program is distributed in the hope that it will be useful,
      12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      14. * GNU General Public License for more details.
      15. *
      16. * You should have received a copy of the GNU General Public License
      17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
      18. *
      19. * @package 2Moons
      20. * @author Slaver <slaver7@gmail.com>
      21. * @copyright 2009 Lucky <douglas@crockford.com> (XGProyecto)
      22. * @copyright 2011 Slaver <slaver7@gmail.com> (Fork/2Moons)
      23. * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
      24. * @version 1.3 (2011-01-21)
      25. * @link http://code.google.com/p/2moons/
      26. */
      27. if(!defined('IN_ADMIN') || !defined('IN_CRON'))
      28. define("STARTTIME", microtime(true));
      29. ignore_user_abort(true);
      30. error_reporting(E_ALL ^ E_NOTICE);
      31. ini_set('zlib.output_compression', 'On');
      32. ini_set('display_errors', 1);
      33. header('Content-Type: text/html; charset=UTF-8');
      34. define('TIMESTAMP', $_SERVER['REQUEST_TIME']);
      35. require_once(ROOT_PATH . 'includes/config.php');
      36. require_once(ROOT_PATH . 'includes/constants.php');
      37. ini_set('session.save_path', ROOT_PATH.'cache/sessions');
      38. ini_set('upload_tmp_dir', ROOT_PATH.'cache/sessions');
      39. ini_set('session.use_cookies', '1');
      40. ini_set('session.use_only_cookies', '1');
      41. session_set_cookie_params(SESSION_LIFETIME, '/');
      42. session_cache_limiter('nocache');
      43. session_name($dbsettings["secretword"]);
      44. ini_set('session.use_trans_sid', 0);
      45. ini_set('session.auto_start', '0');
      46. ini_set('session.serialize_handler', 'php');
      47. ini_set('session.gc_maxlifetime', SESSION_LIFETIME);
      48. ini_set('session.gc_probability', '1');
      49. ini_set('session.gc_divisor', '1000');
      50. ini_set('session.bug_compat_warn', '0');
      51. ini_set('session.bug_compat_42', '0');
      52. ini_set('session.cookie_httponly', true);
      53. ini_set('magic_quotes_runtime', 0);
      54. ini_set('error_log', ROOT_PATH.'/includes/error.log');
      55. if(!defined('LOGIN'))
      56. session_start();
      57. if(!function_exists('bcadd'))
      58. require_once(ROOT_PATH . 'includes/bcmath.php');
      59. require_once(ROOT_PATH . 'includes/GeneralFunctions.php');
      60. set_exception_handler('exception_handler');
      61. require_once(ROOT_PATH . 'includes/classes/class.MySQLi.php');
      62. require_once(ROOT_PATH . 'includes/classes/class.Lang.php');
      63. require_once(ROOT_PATH . 'includes/classes/class.theme.php');
      64. require_once(ROOT_PATH . 'includes/classes/class.Session.php');
      65. $db = new DB_MySQLi();
      66. $THEME = new Theme();
      67. $LANG = new Language();
      68. unset($database);
      69. // Say Browsers to Allow ThirdParty Cookies (Thanks to morktadela)
      70. header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
      71. $UNI = getUniverse();
      72. if(UNIS_MULTIVARS)
      73. require_once(ROOT_PATH.'includes/vars_uni'.$UNI.'.php');
      74. else
      75. require_once(ROOT_PATH.'includes/vars.php');
      76. $CONF = $db->uniquequery("SELECT HIGH_PRIORITY * FROM `".CONFIG."` WHERE `uni` = '".$UNI."';");
      77. $CONF['moduls'] = explode(";", $CONF['moduls']);
      78. $LANG->setDefault($CONF['lang']);
      79. if (!defined('CLI') && !defined('LOGIN') && !defined('IN_CRON') && !defined('AJAX'))
      80. {
      81. $SESSION = new Session();
      82. if(!$SESSION->IsUserLogin()) redirectTo('index.php?code=3');
      83. $SESSION->UpdateSession();
      84. if($CONF['game_disable'] == 0 && $_SESSION['authlevel'] == 0) {
      85. message($CONF['close_reason']);
      86. }
      87. if(!CheckModule(10) && !defined('IN_ADMIN') && request_var('ajax', 0) == 0)
      88. require(ROOT_PATH.'includes/FleetHandler.php');
      89. $USER = $db->uniquequery("SELECT u.*, s.`total_points`, s.`total_rank` FROM ".USERS." as u LEFT JOIN ".STATPOINTS." as s ON s.`id_owner` = u.`id` AND s.`stat_type` = '1' WHERE u.`id` = '".$_SESSION['id']."';");
      90. if(empty($USER)) {
      91. exit(header('Location: index.php'));
      92. } elseif(empty($USER['lang'])) {
      93. $USER['lang'] = $CONF['lang'];
      94. $db->query("UPDATE ".USERS." SET `lang` = '".$USER['lang']."' WHERE `id` = '".$USER['id']."';");
      95. }
      96. $LANG->setUser($USER['lang']);
      97. $LANG->includeLang(array('INGAME', 'TECH'));
      98. $THEME->setUserTheme($USER['dpath']);
      99. if($USER['bana'] == 1)
      100. {
      101. message("<font size=\"6px\">".$LNG['css_account_banned_message']."</font><br><br>".sprintf($LNG['css_account_banned_expire'],date("d. M y H:i", $USER['banaday']))."<br><br>".$LNG['css_goto_homeside']);
      102. exit;
      103. }
      104. if (!defined('IN_ADMIN'))
      105. {
      106. require_once(ROOT_PATH . 'includes/classes/class.PlanetRessUpdate.php');
      107. $PLANET = $db->uniquequery("SELECT * FROM `".PLANETS."` WHERE `id` = '".$_SESSION['planet']."';");
      108. if(empty($PLANET)){
      109. $PLANET = $db->uniquequery("SELECT * FROM `".PLANETS."` WHERE `id` = '".$USER['id_planet']."';");
      110. if(empty($PLANET)){
      111. throw new Exception("Main Planet does not exist!");
      112. }
      113. }
      114. } else {
      115. $USER['rights'] = unserialize($USER['rights']);
      116. $LANG->includeLang(array('ADMIN'));
      117. }
      118. } elseif(defined('LOGIN')) {
      119. //Login
      120. $LANG->GetLangFromBrowser();
      121. $LANG->includeLang(array('INGAME', 'PUBLIC'));
      122. }
      123. if (!defined('AJAX') && !defined('CLI'))
      124. require_once(ROOT_PATH.'includes/classes/class.template.php');
      125. ?>
      Display All

      The post was edited 2 times, last by riotbiz ().