Welcome Guest, Not a member yet? Register   Sign In
DB_Session not working! CI 2.0.2
#1

[eluser]Asiansexynine[/eluser]
DB Session not working for me no any session adding to database table..

file: application/config/database.php
Code:
$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '1111';
$db['default']['database'] = 'main';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

database session table
Code:
CREATE TABLE IF NOT EXISTS  `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 DEFAULT '' NOT NULL,
PRIMARY KEY (session_id)
);

file: application/config/config.php
Code:
$config['sess_cookie_name']        = 'gsession';
$config['sess_expiration']        = 7200;
$config['sess_expire_on_close']    = TRUE;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']        = 'sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']    = 300;

Not add session to database session table. how to fixed?
#2

[eluser]toopay[/eluser]
Did the session works without using database?
#3

[eluser]InsiteFX[/eluser]
For one the session databse table is incorrect there has been a change to it but the documentation has not been updated!
Code:
-- --------------------------------------------------------------

--
-- Table structure for CodeIgniter ci_sessions.
--

DROP TABLE IF EXISTS `ci_sessions`;

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(120)                      NOT NULL,
  `last_activity` int(10)      unsigned DEFAULT 0   NOT NULL,
  `user_data`     text,
  PRIMARY KEY (`session_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

-- -------------------------------------------------------------
--  `user_data` text,       COMMENT - maximum length of 65535 characters.
--  `user_data` mediumtext, COMMENT - maximum length of 16777215 characters.
--  `user_data` longtext,   COMMENT - maximum length of 4294967295 characters.

InsiteFX
#4

[eluser]Asiansexynine[/eluser]
[quote author="InsiteFX" date="1307290831"]For one the session databse table is incorrect there has been a change to it but the documentation has not been updated!
Code:
-- --------------------------------------------------------------

--
-- Table structure for CodeIgniter ci_sessions.
--

DROP TABLE IF EXISTS `ci_sessions`;

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(120)                      NOT NULL,
  `last_activity` int(10)      unsigned DEFAULT 0   NOT NULL,
  `user_data`     text,
  PRIMARY KEY (`session_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

-- -------------------------------------------------------------
--  `user_data` text,       COMMENT - maximum length of 65535 characters.
--  `user_data` mediumtext, COMMENT - maximum length of 16777215 characters.
--  `user_data` longtext,   COMMENT - maximum length of 4294967295 characters.

InsiteFX[/quote]


I am change to

file: application/config/database.php
Code:
$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'main';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

database session table
Code:
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(120)                      NOT NULL,
  `last_activity` int(10)      unsigned DEFAULT 0   NOT NULL,
  `user_data`     text,
  PRIMARY KEY (`session_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

file: application/config/config.php
Code:
$config['sess_cookie_name']        = 'gsession';
$config['sess_expiration']        = 7200;
$config['sess_expire_on_close']    = TRUE;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']        = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']    = 300;

Still not work for me.. Anyone was test DB session and working?
#5

[eluser]toopay[/eluser]
Did the session works without using database?
#6

[eluser]Asiansexynine[/eluser]
[quote author="toopay" date="1307303819"]Did the session works without using database?[/quote]

I am checking session.save_path C:\xampp\tmp where session store. and my CI2 not store session in C:\xampp\tmp

what happen with session on CI2 where to save session on CI2? I don't understand

CI session are working on 1.7.2 the version that use before
#7

[eluser]InsiteFX[/eluser]
Did you load the session library?

InsiteFX
#8

[eluser]Asiansexynine[/eluser]
[quote author="InsiteFX" date="1307327735"]Did you load the session library?

InsiteFX[/quote]

By CI 1.7 do not load the session library.. but work well.. by setting config file.. with CI2 must load the session library? I don't know that.. how to do? and what's files to adding?
#9

[eluser]WanWizard[/eluser]
CI doesn't load anything by default. Either add it to the config/autoload list, or load it manually in your controller.
#10

[eluser]Asiansexynine[/eluser]
I am try to set $autoload['libraries'] = array('session'); in application/config/autoload.php

set config
Code:
$config['sess_cookie_name']        = 'ci_session';
$config['sess_expiration']        = 7200;
$config['sess_expire_on_close']    = TRUE;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']        = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']    = 300;

add code to view.. to check if session work.
Code:
<?php
$session_id = $this->session->userdata('session_id');

echo 'Session ID = ' . $session_id;
?>

Now session_id were generate for my website.. but where session files store?
in phpinfo() show me that session.save_path = C:\xampp\tmp

OK.. take a look at C:\xampp\tmp but no session files generate there..
where is my session files? how to set session.save_path on CI2?




Theme © iAndrew 2016 - Forum software by © MyBB