Domanda

$config['sess_use_database']    = TRUE;

I have came across this in tank auth.Is it neccessary to save session data in database.Im new to this.Can some one tell me why? and what if , if I set it to FALSE.Will it affects the web application?

È stato utile?

Soluzione

The Session class stores session information for each user as serialized (and optionally encrypted) data in a cookie.

Cookie has a limit of 4k.

By setting $config['sess_use_database'] = TRUE; you allow codeigniter to save "cookies" in database so data can be as big as application needs.

You keep asking if it will affect website... If you didn't create application yourself do not change it.

If you know that data in session is going to be bigger than 4k enable it otherwise don't bother with this setting.

Altri suggerimenti

There can be problems with using sessions on some hosts. To combat this session data is saved in the DB instead. Another reason is for sharing sessions among multiple servers when scaling.

From CI user guide:

$config['sess_use_database']    = TRUE;

Once enabled, the Session class will store session data in the DB.

Make sure you've specified the table name in your config file as well:

$config['sess_table_name'] = 'ci_sessions';

CI Session will store the data in COOKIES. So for security reason, you can store in DB.

Another one reason, if you are developing e-commerce site, you will store products in cart. So when user log-in in another system, their cart will be retained if you store session in table.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top