Welcome Guest, Not a member yet? Register   Sign In
ci_session table problem
#1

[eluser]Unknown[/eluser]
Hi,

Keep my data in session but session limit is 4K.therefore i must use ci_session table. however, i have a problem for using ci_session table.

using 1.7.0 version. when i use ci_session, table user_data colon is empty.

i can explain step by step;

1. config file change like this;

$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$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;

2. create table in db (oracle DB)

Code:
CREATE TABLE CI_SESSIONS
(
  SESSION_ID     VARCHAR2(40 BYTE)              DEFAULT 0                     NOT NULL,
  IP_ADDRESS     VARCHAR2(16 BYTE)              DEFAULT 0                     NOT NULL,
  USER_AGENT     VARCHAR2(50 BYTE)              NOT NULL,
  LAST_ACTIVITY  NUMBER                         NOT NULL,
  USER_DATA      VARCHAR2(3000 BYTE)
)
TABLESPACE TS_ERP_DATA
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            MINEXTENTS       1
            MAXEXTENTS       2147483645
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX PK_SESSION_ID ON CI_SESSIONS
(SESSION_ID)
LOGGING
TABLESPACE TS_ERP_DATA
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            MINEXTENTS       1
            MAXEXTENTS       2147483645
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


ALTER TABLE CI_SESSIONS ADD (
  CONSTRAINT PK_SESSION_ID
PRIMARY KEY
(SESSION_ID)
    USING INDEX
    TABLESPACE TS_ERP_DATA
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                MINEXTENTS       1
                MAXEXTENTS       2147483645
                PCTINCREASE      0
               ));

3. Example code for using session;

Code:
class Proje extends Controller {

    function Proje()
    {
        parent::Controller();
        $this->load->model('Proje_model');
        $this->load->model('Genel_model');
        
        $this->load->helper('cookie');
        $this->load->library('session');

        //$this->session->set_userdata('username', $_SERVER['REMOTE_USER']);
        $this->session->set_userdata('username', 'UB7163');
        
        $data = $this->Genel_model->getKullaniciBilgi(); //DATA VALUES FROM DB TABLE
        $this->session->set_userdata('kullanicibilgi', $data);
        
        $usr = $this->session->userdata('kullanicibilgi');

        $this->session->set_userdata('userbirim', $usr[0]['BIRIM_NO']);
        $this->session->set_userdata('useradsoyad', $usr[0]['AD']);


}

P.C. using lots of data keep in session until 4K limit. Limit is full data does not keep in session.

4. For this problem use table but table does not keep session data

example of table data;

session_id :
213c269cbfd13d40766e2a94392a289c
ip_address: 127.0.0.1
user_agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1;
last_activity: 1243264075
user_data: a:4:{s:8:"username";s:6:"UB7163";s:14:"kullanicibilgi";a:0:{}s:9:"userbirim";s:0:"";s:11:"useradsoyad";s:0:"";}

P.C. Only save username data in to user_data colon. other variables don't save because of get data from db table.

if you reply and solve my topic as soon as possible i will be glad.

THANKS.
#2

[eluser]Unknown[/eluser]
i found my problem but i didn't solve. Somebody can help me ?

Get data from DB in model functions. When i use session table to set this data in session, data is empty. Like this;

Without ci_session table run is normal

Code:
class Proje extends Controller {

function Proje()
    {
        parent::Controller();
        $this->load->model('Proje_model');
        $this->load->model('Genel_model');
        
        $this->load->helper('cookie');
        $this->load->library('session');

        //$this->session->set_userdata('username', $_SERVER['REMOTE_USER']);
        $this->session->set_userdata('username', 'UB7163');
        
      
        [b]$data = $this->Genel_model->getKullaniciBilgi(); //DATA VALUES FROM DB TABLE[/b]

/* this data from db by model function (select * from table). This code is run properly without using ci_session table */


        $this->session->set_userdata('kullanicibilgi', $data);
        
        $usr = $this->session->userdata('kullanicibilgi');

        $this->session->set_userdata('userbirim', $usr[0]['BIRIM_NO']);
        $this->session->set_userdata('useradsoyad', $usr[0]['AD']);


}

for ci_session table code;

Code:
class Proje extends Controller {

function Proje()
    {
        parent::Controller();
        $this->load->model('Proje_model');
        $this->load->model('Genel_model');
        
        $this->load->helper('cookie');
        $this->load->library('session');

        //$this->session->set_userdata('username', $_SERVER['REMOTE_USER']);
        $this->session->set_userdata('username', 'UB7163');
        

$data = array(
                array ( AD=>"Ensar Kal",
                        BIRIM_NO=>95,
                       )
);

/* if i se static array instead of db array ([b]$data = $this->Genel_model->getKullaniciBilgi();)ci_session table is run properly and data written in ci_session table */


        $this->session->set_userdata('kullanicibilgi', $data);
        
        $usr = $this->session->userdata('kullanicibilgi');

        $this->session->set_userdata('userbirim', $usr[0]['BIRIM_NO']);
        $this->session->set_userdata('useradsoyad', $usr[0]['AD']);


}

i must use data from db and use ci_session table because of session limitation (4K)

help me.
#3

[eluser]attos[/eluser]
Your problem is in how the USER_DATA column is declared. Oracle limits the VARCHAR2 to 4000 bytes.

Quote:USER_DATA VARCHAR2(3000 BYTE)

You should change the data type to either CLOB (Character Large Object), NCLOB (National Character Large Object) or BLOB (Binary Large Object).




Theme © iAndrew 2016 - Forum software by © MyBB