Welcome Guest, Not a member yet? Register   Sign In
"PROBLEM WITH SESSIONS"
#1

[eluser]Unknown[/eluser]
Hi,

I'm starting with CodeIgniter and I have a problem when handling sessions.
In a controller function performs a query to the database and get in the session data I get, through $ this-> session-> set_userdata ($ NewData), the library session is loaded into the autoload.php .
later, this same function call controller to another controller through redirect ('/ page2'), and in this bag session data. The problem is, that I have no data in the session.

I do not modified the config.php file, which corresponds to the session variables and cookies is:


"*
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| 'session_cookie_name' = the name you want for the cookie
| 'encrypt_sess_cookie' = TRUE/FALSE (boolean). Whether to encrypt the cookie
| 'session_expiration' = the number of SECONDS you want the session to last.
| by default sessions last 7200 seconds (two hours). Set to zero for no expiration.
| 'time_to_update' = how many seconds between CI refreshing Session Information
|
*/
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$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;

/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookie_prefix' = Set a prefix if you need to avoid collisions
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
| 'cookie_path' = Typically will be a forward slash
|
*/
$config['cookie_prefix'] = "";
$config['cookie_domain'] = "";
$config['cookie_path'] = "/";
"


How I can fix it?.

Thank you very much.
#2

[eluser]Ivar89[/eluser]
Code:
$config[‘sess_use_database’]  = TRUE; //You have this false
#3

[eluser]danmontgomery[/eluser]
[quote author="Ivar89" date="1277400780"]
Code:
$config[‘sess_use_database’]  = TRUE; //You have this false
[/quote]

This wouldn't cause session data to be lost

You're going to have to be more specific, tell us what you're trying to do, show us some code, etc
#4

[eluser]Ivar89[/eluser]
[quote author="noctrum" date="1277403120"][quote author="Ivar89" date="1277400780"]
Code:
$config[‘sess_use_database’]  = TRUE; //You have this false
[/quote]

This wouldn't cause session data to be lost

You're going to have to be more specific, tell us what you're trying to do, show us some code, etc[/quote]

That's true but I couldn't really figure something else out with the info he shared I was a little confused about the real problem and I say Database query so this came to mind.
#5

[eluser]WanWizard[/eluser]
What is the amount of data you're trying to store in the cookie? Any other cookies in the HTTP header?

There is a 4Kb limit to a single cookie, and webservers limit the total size of the HTTP header (for Apache the default is 8190 bytes, IIS 16Kb).

I've heard more reports about people losing cookies when using a "Location" redirect. A "Refresh" seems to work more reliable, but has some issues with older browsers.
#6

[eluser]Unknown[/eluser]
Hi,

Is solved. The problem was that after putting the data in the session redirected to another page through redirect ('page'), added as the second parameter 'refresh' and it worked.

Thank you, very much.




Theme © iAndrew 2016 - Forum software by © MyBB