CodeIgniter version 3.x: Loading "Session" library reports ini_set warining - php

I am using Codeigniter 3.0.1 in a Wamp64 installation (PHP Ver 5.6.19, Apache 2.4.18) on a Windows Server 2012 R2.
When I have the line:
$autoload['libraries'] = array('session');
in autoload.php I get the following error on startup of my application:
ini_set() A session is active You cannot change the session module's
ini settings at this time. Filename: libraries/Session.php Line
Number: 313
If I take that line out of autoload.php and put the following line in the contructor function of the controllers that actually use the session data:
$this->load->library("Session")
I get the same error, but only when I start one of those controllers.
I have reviewed multiple answers to this question on stackoverflow:
Do you have a session_start() in your php code: NO - I have searched every piece of code included in this project and there is no session_start() anywhere
Do you have session.auto_start set equal to 0 (zero) in php.ini - YES
Neither of these answers solves my problem.
Session info is being written out to C:\temp on the server. I see the file is created when I start the controller that first loads the Session library so the web server seems to have write access to the C:\temp folder.
The other interesting thing is that I have no problem with the installation on my test server (Windows 7, php version 5.6.32)
Can anyone offer any suggestions? Thanks!
One more piece of information: This was an upgrade from 2.x to 3.0. I did delete the \system sub folder and replaced it with the V3 \system folder.

Found it.
The issue was an Ajax library (Sijax) which external to Codeigniter instantiated an instance of the class so that the methods could be called via Ajax. The new(class) triggered loading the Session class again, which ran through the initialization and tried to create the session again.
I removed the autoload of the Session class, and moved loading it to the Classes that require it, checking first to see if the Class already exists before calling the loader.

Related

Undefined variable notice when trying to use Spotify API PHP Wrapper

I hope you are well. I am brand new to coding and have spent a lot of time trying to find a solution to my question, without much luck.
I was trying to utilize Spotify's API with PHP but ran into thus far unsurmountable hurdles. Please see steps taken below:
1.) I downloaded the Spotify PHP Wrapper library here https://github.com/jwilsson/spotify-web-api-php, and saved it in the same directory as my app. I then created a composer.json file as below :
{
"require": {
"jwilsson/spotify-web-api-php": "^1.0.0"
}
}
2.) After creating and saving the composer.json file, I ran "composer install" in terminal in the same directory as where the composer.json file was stored, which led to the creation of a composer.lock file and a vendor folder.
3.) I then moved the composer.lock, composer.json and vendor folders to my online hosting service (ecowebhosting) via firebug, so that I can run and test the code. I also created a .php file that I moved to the server as well.
In my .php page, i declared the required files as such (below) and ran a sample query form the Spotify API PHP Wrapper documentation on github, to confirm whether or not I successfully loaded the library (the autoload.php folder was automatically created in the "Vendor" folder, after I performed step 2 above):
require 'vendor/autoload.php';
$tracks = $api->getAlbumTracks('1oR3KrPIp4CbagPa3PhtPp');
print_r ($tracks);
When I run the code above, I get the error below:
Notice: Undefined variable: api in /home/sites/amanka.com/public_html/content/SmallApps/ListeningPod/home.php on line 8 Fatal error: Call to a member function getAlbumTracks() on a non-object in /home/sites/amanka.com/public_html/content/SmallApps/ListeningPod/home.php on line 8
This error causes me to think that I have not installed the Library correctly. Please any ideas where I might be going wrong?
Thanks a lot

Laravel 5 class

I installed laravel 5.1 on my windows 7, after that i tried to open blog/app/Htttp/routes.php.Now there's a error on my browser saying
"Fatal error: Class 'Route' not found in
C:\xampp\htdocs\Laravel_1\blog\app\Http\routes.php on line 14".
How do i remove this error?
Before a class is available in PHP you will need to require/include it. As you have opened up the file directly in the browser, the laravel application is not bootstrapped and none of the dependencies are loaded to be used.
If you open up public/index.php, you will find a line that says
require __DIR__.'/../bootstrap/autoload.php';
// this later calls composer autoload which compiles a file
// that includes all the classes that you have specified in your `composer.json`.
Now that you have opened the file directly, non of the classes are included and hence you get the error.
I am not sure about your intentions for opening that file directly in the browser. I can only suggest you that the error is expected and you should go through the public/index.php for the application to work properly.

Codeigniter 3 dev Unable to load the requested class

I'm new in CI and now I'm trying to use CodeIgniter 3 to develop my site. I just only extract the framework and change only one think in config/autoload.php file:
$autoload['libraries'] = array('database','input');
when I run the site, an error occur:
Unable to load the requested class: Input
When I tried it with CI version 2.2.0 stable, every thing is OK, no errors
Could some one explain why and help me to solve it?
As of documentation input library is loaded by default.
This class (input) is initialized automatically by the system so there is no need to do it manually.
Autoloading documentation http://www.codeigniter.com/userguide3/general/autoloader.html
By default the library load from system/core folder in you CI. But the Input library is located on the core folder so you need to give relative path to the Input.php like this
$autoload['libraries'] = array('database','../core/input');

Original PHP Session with Zend Framework 2

Zend Framework 2 is not letting me use orginal PHP session. I am using Responsive File Manager Application that is in public folder of zend framework 2. Whenever the dialog of file manager opens, I get following error.
Warning: Class __PHP_Incomplete_Class has no unserializer in E:\xampp\htdocs\MantissaAdmin\public\ResponsiveFilemanager\filemanager\config\config.php on line 2
Where on line 2, the code is
session_start();
How can I make it so that Zend framework 2 do not interfere with the file manager session.
This is not an issue of ZF2. There is a serialized object in your session which php tries to unserialize when session_start is called. But because PHP can't find the class (which is not declared), it uses __PHP_Incomplete_Class instead.
See: PHP: unserialize - Manual
The best way to fix: Register an autoloader to load missing classes. You can dump the class name this way:
ini_set('unserialize_callback_func', '__unserialize_callback_func');
function __unserialize_callback_func($classname)
{
var_dump($classname);
}
session_start();
In order to work with other 3rd party libraries and share sessions across software that may not be ZF2 related; you will need to ensure that you still provide access to the ZF2 autoloader as well as module autoloading. In the shared software make certain before the session starts that you bootstrap the ZF2 autoloader and initialize the ZF2 Application.
$cwd = getcwd();
chdir('/path/to/zf2-application');
require 'init_autoloader.php';
Zend\Mvc\Application::init(require 'config/application.config.php');
chdir($cwd);
session_start();

CakePHP DebugKit causes an error

I want deploy my project on the server, so I need to disable DebugKit. I removed CakePlugin::load('DebugKit') from bootstrap.php and disabled it in AppController.
After that I started getting error 'Fatal error: Class "CakeSession" not found in /vagrant/lib/Cake/Controller/Component/SessionComponent.php on line 69'.
How can I solve my problem?
The error would indicate that your Cake installation is incomplete. Make sure you extracted the entire framework into your document root.
As for the DebugKit, you don't need to remove it explicitly, as it ceases to be loaded once you put the debug level in your app/Config/core.php file to 0 (as live applications should have their debug setting set).

Categories