Welcome Guest, Not a member yet? Register   Sign In
CI Sessions the guide! Maybe...
#1

[eluser]Clooner[/eluser]
Again having to figure out how things work with the sessions is crap! There for this guide for my own reference Big Grin So far I have found if you want to use the CI sessions you have to correctly set it up by:

1: Set a correct site wide cookie domain!
Code:
$config['cookie_domain'] = ".yourdomain.com"; // a . before the domain and no subdomains!

2: Remove underscores from cookie names
Code:
$config['sess_cookie_name'] = "nounderscore";

3: Enable the database sessions
Code:
CREATE TABLE IF NOT EXISTS  `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(128) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id)
);
Code:
$config['sess_use_database'] = TRUE;

Somehow if you fail to do any of these steps you will run into trouble sooner or later! Am I forgetting something?
#2

[eluser]GSV Sleeper Service[/eluser]
codeigniter sessions are weird, I experienced a fair few problems with them, mainly with IE 7 (for reasons still unknown, must do some more testing)
I recommend the 'native session' library, which you can find in the CI wiki, you lose the database stuff, but I can live without that, and they act just like regular old PHP sessions, ie none of this stuffing everything into a cookie oddness.
#3

[eluser]danmontgomery[/eluser]
n0xie has a link to CI's session (cookie, actually) issues with IE in his signature.
#4

[eluser]Clooner[/eluser]
Here's a question: How would I be able to correctly test if the sessions/cookies are functioning.

It works here on my computer under IE6+7+8, FF3, Safari, Chrome etc but somehow I don't have enough conversions with a new site of mine.

I fear that users might exit the page when they can't anything to the basket!
#5

[eluser]WanWizard[/eluser]
Run a test?

For example, after a user logs in, set some session values, and redirect to an intermediate URI. Validate the session, and if ok, redirect again to a 'logon succesful' page, of not, redirect to a 'session error' page. Don't forget to log as much as possible from the failed session, like as much browser info as possible, $_SERVER contents, etc. If possible, see if you can retrieve the browsers local date since that might be an issue too.
#6

[eluser]Clooner[/eluser]
[quote author="WanWizard" date="1276612656"]Run a test?

For example, after a user logs in, set some session values, and redirect to an intermediate URI. Validate the session, and if ok, redirect again to a 'logon succesful' page, of not, redirect to a 'session error' page. Don't forget to log as much as possible from the failed session, like as much browser info as possible, $_SERVER contents, etc. If possible, see if you can retrieve the browsers local date since that might be an issue too.[/quote]

Thanks for the suggestion! I've been testing this a few hours but couldn't detect any errors with ci_sessions... It all seems to be working fine. But still the conversions are not up to par!
#7

[eluser]WanWizard[/eluser]
What conversions? You mean (concurrent) sessions?

There aren't many load testers available (for free) that support cookies, which is required to test sessions. You could have a look at Siege, which is on my list to test (but the list is long...).
#8

[eluser]Clooner[/eluser]
[quote author="WanWizard" date="1276630344"]What conversions? You mean (concurrent) sessions?

There aren't many load testers available (for free) that support cookies, which is required to test sessions. You could have a look at Siege, which is on my list to test (but the list is long...).[/quote]
I mean a marketing conversion... Because a certain page didn't convert I feared that the site was crooked. The problem must be somewhere else then.
#9

[eluser]LuckyFella73[/eluser]
I know this is an old thread but it was opened to be some kind
of guide to avoid session problems. I thought this info may be usefull
for new CI users who find this thread:
Code:
$config['cookie_domain'] = ($_SERVER['SERVER_NAME'] == 'localhost' ? '' : preg_replace('/^www\./', '', $_SERVER['SERVER_NAME']));

As far as I know Phil Sturgeon posted that a time ago. This way you
don't have to worry about setting the cookie domain or changing the
value when uploading you project.




Theme © iAndrew 2016 - Forum software by © MyBB