I recently ugraded to php5 for one of my clients and my sessions no longer work properly. The code base has worked perfectly under php4 for years. The problem is definitely related to cookies (won't set). I have troubleshooted this problem extensively and still cannot get a cookie set properly. I threw together a simple session script and it works fine. However, my more complex session code does not. I've tried ini changes and code changes to no avail. Anyone aware of session /cookie handling changes made to php5? Any new gotchas? Grant
This section is called near top of index.php before any output. Nothing complex, just standard session starting. I also tried specifying domain and cookie path parameters, but it didn't help. I also ensure session auto start is OFF in php.ini $expireTime = 60*60*24; // 1 day session_name("supertime"); session_set_cookie_params($expireTime); //set expiration time session_start();
I did verify the critical settings were identical, but didn't compare everything. I will run a more thorough comparison and report back.
Try re-ordering your code like this: $expireTime = 60*60*24; // 1 day session_set_cookie_params($expireTime); //set expiration time session_start(); session_name("supertime"); PHP: I haven't encountered such an error before, maybe its the order (doubtful, but worth a try), or it is your PHP settings. Maybe check your PHP.ini settings. If not, check you have permission to modify php.ini. I believe you should be looking under sessions in php.ini to see if session cookies have been enabled. From memory it's something like sessions.cookies.enable = 1 that it should be. Not sure if that's the right name, it's similar though.
I will give the reorder a try. I did verify the ini setting you mentioned. Appreciate the input fellas.
Turns out I had an carriage return above opening php tag in one of my include files. Funny how we always overlook the simple stuff. Thanks again for the suggestions.