Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter lost my session
#11

[eluser]WanWizard[/eluser]
You shouldn't use the session as a replacement for your database.
Only store the information in the session that is required to maintain state in your application.

From an authentication / authorisation perspective, the user_id and user_name, and the user's rights structure, is sufficient for the application. The single form that needs to display more information about the user can retrieve it from the database using the stored user_id.
#12

[eluser]Lokut Da[/eluser]
[quote author="tkyy" date="1282883065"]as the first response said you should use database sessions[/quote]

Yes, i'm using database sessions. Sad I configured my config.php file:

Code:
$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;

And I have created the ci_sessions table.

[quote author="WanWizard" date="1282915073"]You shouldn’t use the session as a replacement for your database.[/quote]

Yes, i know, it is an example only Smile I need session unlimited to my application, because i don't know how much Kb session i might need.

What do u think? (Sorry my english Tongue)

Thanks.
#13

[eluser]WanWizard[/eluser]
If you check the contents of the ci_sessions table, do you see any session records being created? If so, do you see a new record being created for every page request?

If so, there's something wrong with your session cookie. Make sure:
- there is no underscore in the cookie name (rename ci_session to something else)
- there is no underscore in the cookie prefix, and that the prefix doesn't start with a digit
- the cookie domain is properly configured, matches your host, and doesn't contain illegal hostnames (such as localhost!)
- the cookie path is properly configured ( at least '/' for the root of your host )
- the time on your server and your client is correct
#14

[eluser]Lokut Da[/eluser]
Ouu ok ok WanWizard, thanks for ur answers and let me check it.

Regards.
#15

[eluser]Lokut Da[/eluser]
Damn! :S I don't know what happen...

I can't do nothing to resolve that

Look:

Code:
$config['sess_cookie_name']        = 'cisession';
$config['sess_expiration']        = 7200;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']        = 'cisessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 300;

//----------------
$config['cookie_prefix']    = "";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";

I changed the name cookie's and nothing happen. I checked the configuration I guess it's ok!

WanWizard, one question, ¿what do u mean about that?:

"the time on your server and your client is correct "

Thanks for your patience.

Regards.
#16

[eluser]tkyy[/eluser]
try changing your cookie prefix around, sometimes codeigniter has problems with specific cookie names. he means that the time on your server is updated and proper so that the cookie doesnt destroy itself as it creates itself.

also try turning off useragent and ip matching (although this will leave you vulnerable to cookie stealing xss if your application is going to be widely used, if it is something for client and private use don't worry about it though) as sometimes this causes the session to explode in odd situations.
#17

[eluser]Lokut Da[/eluser]
Code:
$config['sess_cookie_name']        = 'lac';
$config['sess_expiration']        = 7200;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']        = 'cisessions';
$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']    = "lac";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";

Hi tkyy, how have u been?

I have not really been able to fix this.

I am thinking to test native sessions php. But, is it really? can't CI to manage session naturally??

Thanks.
#18

[eluser]WanWizard[/eluser]
Your cookie domain is empty. It will be rejected by any modern browser.

It should contain the hostname of your website, or the domain part of it if you want cookies to be available to all your sites.
#19

[eluser]inst[/eluser]
You should use native php sessions. The codeigniter session database solution is best for low traffic websites.
If you use database sessions you make request to database every time when you want to read/write an session
#20

[eluser]Lokut Da[/eluser]
Hey guys thanks for ur answers Smile I could to use sessions in CI Big Grin.

I had to use Native Sessions and everything is ok!

Really, thanks so much!

Regards!!




Theme © iAndrew 2016 - Forum software by © MyBB