CodeIgniter Forums
SESSION: ci_sessions database table not populating - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: SESSION: ci_sessions database table not populating (/showthread.php?tid=63038)



SESSION: ci_sessions database table not populating - gloosemore - 09-18-2015

I've been pulling my hair out over this for days. I posted a similar post earlier but it wasn't laid out properly i think. I really need detailed information on how to proceed instead of hints on where the look please.

First of all i downloaded 3.0.1 and built some simple pages from scratch to see if i could get sessions working.

Basically i set sessions in config to be database, and i set the database name as ci_sessions. I load the ci_sessions table. When i go to autoload sessions, when user starts using the website (right now i'm running it locally using WAMP so i'm the only user), i get an error message whenever i load the page. Also, ci_sessions table in a_cfg database does not populate at all when i autoload 'session' or try loading a page that tries to set some session variables.


This is the error message:

Code:
A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET `last_activity` = 1442580701, `user_data` = 'a:2:{s:9:\"user_data\";s:0:\"\"' at line 1

UPDATE SET `last_activity` = 1442580701, `user_data` = 'a:2:{s:9:\"user_data\";s:0:\"\";s:7:\"user_id\";i:1;}' WHERE `session_id` = 'd8ca004aaa0c4db687a91ae78d996afd'

Filename: libraries/Session.php

Line Number: 289

SOMEBODY indicated it might have something to do with "Filename: libraries/Session.php" but did not say what so i had no idea how to fix it.

It looks like its trying to write information to the PREVIOUS version of ci_sessions table based on the column names. No idea why its doing this as i started coding from 3.0.1 and system file is as it should be with no changes.

Here is the view that tries to set the session variable that triggers the error whenever the view loads:

Code:
<html>
<head>
</head>
<body>

Hey Test 1

<?php

$arr = array('user_id' => 1);
$this->session->set_userdata($arr);

?>

</body>
</html>

Here is the database file in config->database.php:

Code:
$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
'dsn' => '',
'hostname' => '166.62.32.126',
'username' => 'xxx',
'password' => 'xxx',
'database' => 'a_cfg',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

The ci_sessions table is found in the a_cfg database.

And here is the sessions configuration in config.php

Code:
$config['encryption_key'] = '123';

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = "ci_sessions";
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

Please I'm desperate for help. Please be detailed as i am a self-taught coder that is very simplistic. Thanks in advance, Geoff


RE: SESSION: ci_sessions database table not populating - mwhitney - 09-18-2015

(09-18-2015, 06:11 AM)gloosemore Wrote: I've been pulling my hair out over this for days. I posted a similar post earlier but it wasn't laid out properly i think. I really need detailed information on how to proceed instead of hints on where the look please.

First of all i downloaded 3.0.1 and built some simple pages from scratch to see if i could get sessions working.

Basically i set sessions in config to be database, and i set the database name as ci_sessions. I load the ci_sessions table. When i go to autoload sessions, when user starts using the website (right now i'm running it locally using WAMP so i'm the only user), i get an error message whenever i load the page. Also, ci_sessions table in a_cfg database does not populate at all when i autoload 'session' or try loading a page that tries to set some session variables.


This is the error message:


Code:
A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET `last_activity` = 1442580701, `user_data` = 'a:2:{s:9:\"user_data\";s:0:\"\"' at line 1

UPDATE SET `last_activity` = 1442580701, `user_data` = 'a:2:{s:9:\"user_data\";s:0:\"\";s:7:\"user_id\";i:1;}' WHERE `session_id` = 'd8ca004aaa0c4db687a91ae78d996afd'

Filename: libraries/Session.php

Line Number: 289

SOMEBODY indicated it might have something to do with "Filename: libraries/Session.php" but did not say what so i had no idea how to fix it.

It looks like its trying to write information to the PREVIOUS version of ci_sessions table based on the column names. No idea why its doing this as i started coding from 3.0.1 and system file is as it should be with no changes.

Download CI3 again. Delete everything in your system directory. Place the contents of the CI3 system directory in your system directory.

The libraries/Session.php file is from CI2 and should have been removed when you upgraded to CI3, but you either missed or misread that part of the upgrade instructions.


RE: SESSION: ci_sessions database table not populating - gloosemore - 09-18-2015

(09-18-2015, 07:15 AM)mwhitney Wrote:
(09-18-2015, 06:11 AM)gloosemore Wrote: I've been pulling my hair out over this for days. I posted a similar post earlier but it wasn't laid out properly i think. I really need detailed information on how to proceed instead of hints on where the look please.

First of all i downloaded 3.0.1 and built some simple pages from scratch to see if i could get sessions working.

Basically i set sessions in config to be database, and i set the database name as ci_sessions. I load the ci_sessions table. When i go to autoload sessions, when user starts using the website (right now i'm running it locally using WAMP so i'm the only user), i get an error message whenever i load the page. Also, ci_sessions table in a_cfg database does not populate at all when i autoload 'session' or try loading a page that tries to set some session variables.


This is the error message:



Code:
A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET `last_activity` = 1442580701, `user_data` = 'a:2:{s:9:\"user_data\";s:0:\"\"' at line 1

UPDATE SET `last_activity` = 1442580701, `user_data` = 'a:2:{s:9:\"user_data\";s:0:\"\";s:7:\"user_id\";i:1;}' WHERE `session_id` = 'd8ca004aaa0c4db687a91ae78d996afd'

Filename: libraries/Session.php

Line Number: 289

SOMEBODY indicated it might have something to do with "Filename: libraries/Session.php" but did not say what so i had no idea how to fix it.

It looks like its trying to write information to the PREVIOUS version of ci_sessions table based on the column names. No idea why its doing this as i started coding from 3.0.1 and system file is as it should be with no changes.

Download CI3 again. Delete everything in your system directory. Place the contents of the CI3 system directory in your system directory.

The libraries/Session.php file is from CI2 and should have been removed when you upgraded to CI3, but you either missed or misread that part of the upgrade instructions.

Thank you for your quick reply.

I did what you say and it has no effect. Here is the session part of the system directory as i just reinserted in from CI3:


Code:
system/
   core/
   database/
   fonts/
   helpers/
   language/
   libraries/
      Cache/
      Javascript/
      Session/
          drivers/
               index.html
               Session_database_driver.php
               Session_files_driver.php
               Session_memcached_driver.php
               Session_redis_driver.php
          index.html
          Session.php
          Session_driver.php
          SessionHandlerInterface.php


Isn't that the appropriate file structure?

If not, how do i proceed?

Thanks
  


RE: SESSION: ci_sessions database table not populating - mwhitney - 09-18-2015

Is there a Session.php file in the root of your /system/libraries/ directory? If there is, then you have missed the step of deleting the contents of the directory before copying over the files from CI3.

If there is not a Session.php file in the root of your /system/libraries/ directory, then your error message should have at least changed. If it did not, then make sure you don't have a Session.php file in your /application/libraries/ directory. Of course, this would imply that you were using some sort of customized Session library before and you may still have other issues to resolve in migrating to CI3.


RE: SESSION: ci_sessions database table not populating - gloosemore - 09-18-2015

(09-18-2015, 08:08 AM)mwhitney Wrote: Is there a Session.php file in the root of your /system/libraries/ directory? If there is, then you have missed the step of deleting the contents of the directory before copying over the files from CI3.

If there is not a Session.php file in the root of your /system/libraries/ directory, then your error message should have at least changed. If it did not, then make sure you don't have a Session.php file in your /application/libraries/ directory. Of course, this would imply that you were using some sort of customized Session library before and you may still have other issues to resolve in migrating to CI3.

**SOLVED**

You were right. The problem was with my WAMP testing server. Though i was changing the files i uploaded to WAMP, if a directory or filename already existed on the WAMP testing server the previous file was never overwritten. By going into WAMP and deleting everything on the testing server then uploading again everything seems to be working fine now. I've also tested it outside of WAMP by putting the pages online and everything seems to be working. Thanks for your help.


RE: SESSION: ci_sessions database table not populating - Narf - 09-23-2015

Don't double post, be patient.

This topic is now just a duplicate of http://forum.codeigniter.com/thread-63015.html