Welcome Guest, Not a member yet? Register   Sign In
aren't cookies global?
#11

The redirect function is as it should be and url_helper.php is not corrupt - at least the redirect function (as shown) is not.

"refresh" vs "location" makes no difference on what ultimately happens. redirect() tells to browser to "go to this URL" and the call to exit tells the server to stop executing the current script. Once the script stops then the server forgets all about what it just did.

When the browser is asked for a URL (in this case due to the redirect) it sends any cookies related to that URL. When a valid session cookie is seen during the session class load-up any related session data will be recovered.

It is not clear how/when you are loading the session class. But since the session data is not recovered then sessions are not configured correctly. The config problem could be either the session and/or cookie $config items.

Share those config items and maybe someone will spot a problem.
Reply
#12

(This post was last modified: 11-13-2017, 03:50 PM by richb201.)

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;

On the session load, I am actually loading it in autoload:
$autoload['libraries'] = array('session','database');
$autoload['helper'] = array('url','form');

In the first controller user.php, the this->session->setuserdata() works fine. In the second controller, configuration.php, this->session->setuserdata() also works fine. It is just that the session->userdata gets blanked out after the exit() in the first controller.
proof that an old dog can learn new tricks
Reply
#13

(This post was last modified: 11-13-2017, 06:33 PM by dave friend.)

OK. Your problem is that when using $config['sess_driver'] = 'files'; the $config['sess_save_path'] MUST describe the absolute path to the folder used for the files. On a linux system that might be something like `/var/www/project_folder/sessions/`. The point is it must be a complete path from the root of the drive to the folder to hold the files.

Read the Files Driver section of the documentation carefully for other vital information about using the files driver.

Depending on your server, you might need a different value for $config['cookie_domain']. If the empty string does not work then you might want to try '.example.com'; or maybe '.example.com/' .

If you are going to use cookies to hold data (instead of sessions) it is strongly recommended to use SSL (https://) and use these cookie settings

PHP Code:
$config['cookie_secure'] = TRUE;
$config['cookie_httponly'] = TRUE
Reply
#14

Thanks Dave. It is working a little better now. What I mean is it works intermittently. I have been trying to figure out why that is. There seems to be a delay in writing (or reading) the cookie. I wish there was a way i could force the system to write the cookie rather than it just happening on its own schedule. I will debug it a little more. Today my xdebug again started crashing Apache. That happened last week for a few days, and then it just went away by itself, and it started by itself again today, so I cold booted and am hoping for the best.
proof that an old dog can learn new tricks
Reply
#15

I set mine up like CodeIgniter 4 Development

Create the writable directory in the root like CI 4

Then I setup my config sessions like below.

PHP Code:
$config['sess_driver'            'files';
$config['sess_cookie_name'       'ci_session';
$config['sess_expiration'        7200;
$config['sess_save_path'         APPPATH.'../writable' //NULL;
$config['sess_match_ip'          FALSE;
$config['sess_time_to_update'    300;
$config['sess_regenerate_destroy'] = FALSE

This works just fine for me.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB