Welcome Guest, Not a member yet? Register   Sign In
New CI 1.7 session class database error
#11

[eluser]Randy Casburn[/eluser]
Do you mean using sessions with a table created with the CREATE TABLE statement from this page:

http://ellislab.com/codeigniter/user-gui...sions.html

does not work? Or something else didn't work?

Randy
#12

[eluser]dmiden[/eluser]
It didn't work using the field set to 'NOT NULL'.

Yes, I mean using a database to store the default session data and also custom user data (user_data field).
#13

[eluser]CIfan1000[/eluser]
Hi Randy,

I did confirm in the table that the user_data field is TEXT.

I just copied the table definition from the CI session documentation and ran it in MySQL:

CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(50) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id)
);

I have attached a screencap of my MySQL Table Editor - Please take a look - you'll notice that the Default value of the user_data field is NULL - is this ok?

MySQL is version 5.0.51a
#14

[eluser]dmiden[/eluser]
CIFan1000, there's no problem having set the field to NULL Wink
#15

[eluser]CIfan1000[/eluser]
Dear user dmiden - With all due respect could I ask you not to post further in this please?

I am trying to understand Randy's posts and you posts are confusing me.
#16

[eluser]Randy Casburn[/eluser]
@Daniel - The code in the session class substantiates what you are saying. There is no question about that. I just can't figure out why it works for one of us and not the other. I'm missing something in my config. I'll look later...so you're fix is the likely the most expedient.

@ CIfan1000 - The best thing to do is to set the user_data column to allow null values.

It won't hurt your app to do that.

I'll keep looking and see if this is a doucmentation error. The 1.7.0 Session Class has substantial changes.

Thanks for your patience -- and Daniel thanks for you help.

Randy
#17

[eluser]CIfan1000[/eluser]
Dear Randy:

Quote:Do you mean using sessions with a table created with the CREATE TABLE statement from this page:

http://ellislab.com/codeigniter/user-gui...sions.html

does not work? Or something else didn’t work?

Just to clarify, I did use the CREATE TABLE statement from the page you mention - and MySQL accepted it fine, so I do not think that is the problem.
#18

[eluser]CIfan1000[/eluser]
Hi Randy,

Also, and I think this may be important, I came across a similar problem when I was evaluating and decided to not go with Drupal.

At that time, a developer pointed out that on some platforms, eg Windows, a text field in MySQL cannot be set to NOT NULL - this will create an error.
#19

[eluser]CIfan1000[/eluser]
Hi Randy,

I erased my ci_sessions table, copied the following out of the CI sessions manual:

CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT ‘0’ NOT NULL,
ip_address varchar(16) DEFAULT ‘0’ NOT NULL,
user_agent varchar(50) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id)
);

Then modified it so that the user_data field no longer was set to NOT NULL


CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT ‘0’ NOT NULL,
ip_address varchar(16) DEFAULT ‘0’ NOT NULL,
user_agent varchar(50) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text,
PRIMARY KEY (session_id)
);

Then I ran this in MySQL, and used this table with:
$config['sess_use_database'] = TRUE;

and things seem to be running fine - I can see the session variables are now being stored in the user_data field.

BUT now I am a little scared that I am not using this table like the way CI would like me to use it - is there any risk of bugs doing it this way?
#20

[eluser]CIfan1000[/eluser]
Hi Randy,

Earlier you said:

Quote:As a side note, you cannot set a default value in your table definition for TEXT datatype.

Randy

I am a little confused by this because it seems that if I run the standard CREATE TABLE command out of the CI session documentation (user_data text NOT NULL,) then MySQL Admin shows that the default value for this field is NULL - please see my attachment earlier.

Could you clarify please? Sorry, but my MySQL knowledge is limited.




Theme © iAndrew 2016 - Forum software by © MyBB