-
pb.sajjad Junior Member
 
-
Posts: 39
Threads: 19
Joined: Nov 2015
Reputation:
2
I have a question about codeigniter sessions size...
Is the session stored on client side or server side?
what about size limitation? I read some topics, and some developers said 4KB and they said only session id is stored in browser. If this is true, what about concurrent users? I stored some data, like user_id, username, user_first_name, user_last_name, user_avatar_name using set_userdata (and also some flashdata), instead of use queries in every page, and use these values through the whole site. Now my question is about many concurrent users that want to logged in, in the same time and surf the site (like an online exam or anything). What about session size limitation? Is it considered for one user or all users?
any help?
-
Diederik Senior Member
   
-
Posts: 299
Threads: 0
Joined: Jan 2015
Reputation:
20
The session data is always stored serverside. A cookie is data stored in the client side. When you use a session in PHP a small cookie is created (a session id token). That way the session id is stored clientside and PHP makes the connection between the user (based on the session id) and all the data inside the session (stored on server).
The SQL that is used to create the table that stores the sessions:
Code: CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(45) DEFAULT '0' NOT NULL,
user_agent varchar(120) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id),
KEY `last_activity_idx` (`last_activity`)
);
The data itself is stored as a TEXT field which can hold 64 Kilobytes. The 4K you refer to is the max size of a cookie (all cookies for a domain are counted together).
-
Narf Me
      
-
Posts: 1,589
Threads: 1
Joined: Oct 2014
Reputation:
121
(12-07-2015, 01:13 AM)Diederik Wrote: The session data is always stored serverside. A cookie is data stored in the client side. When you use a session in PHP a small cookie is created (a session id token). That way the session id is stored clientside and PHP makes the connection between the user (based on the session id) and all the data inside the session (stored on server).
The SQL that is used to create the table that stores the sessions:
Code: CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(45) DEFAULT '0' NOT NULL,
user_agent varchar(120) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id),
KEY `last_activity_idx` (`last_activity`)
);
The data itself is stored as a TEXT field which can hold 64 Kilobytes. The 4K you refer to is the max size of a cookie (all cookies for a domain are counted together).
This SQL code refers to the CI2 sessions ... which are in fact always stored in a cookie. Even when you use a database, it's just a duplicate of the cookie-stored data.
CI3 matches your description, but uses a different database structure (that is, if you pick the database session driver).
-
pb.sajjad Junior Member
 
-
Posts: 39
Threads: 19
Joined: Nov 2015
Reputation:
2
(12-07-2015, 04:19 AM)Narf Wrote: (12-07-2015, 01:13 AM)Diederik Wrote: The session data is always stored serverside. A cookie is data stored in the client side. When you use a session in PHP a small cookie is created (a session id token). That way the session id is stored clientside and PHP makes the connection between the user (based on the session id) and all the data inside the session (stored on server).
The SQL that is used to create the table that stores the sessions:
Code: CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(45) DEFAULT '0' NOT NULL,
user_agent varchar(120) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id),
KEY `last_activity_idx` (`last_activity`)
);
The data itself is stored as a TEXT field which can hold 64 Kilobytes. The 4K you refer to is the max size of a cookie (all cookies for a domain are counted together).
This SQL code refers to the CI2 sessions ... which are in fact always stored in a cookie. Even when you use a database, it's just a duplicate of the cookie-stored data.
CI3 matches your description, but uses a different database structure (that is, if you pick the database session driver).
I'm using CI3, and know about different drivers. My mean was not about database driver for sessions. I mean default driver (file driver) and store some data. As you know, we could have flashdata, tempdata ,... I put some necessary alarms in flashdata, and this is will removed automatically for next request. I put some info (and now, it is just user_id) in a session:
$this->session->set_userdata('user_id', $user_id);
set this for use in other controllers and...
For this type, if many users logged in and want to surf website, is there size limitation?
I want to know this.
thanks.
-
Narf Me
      
-
Posts: 1,589
Threads: 1
Joined: Oct 2014
Reputation:
121
|