CodeIgniter Forums

Full Version: updated to current ci but base_url() defect
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
the base_url function does not return the port number like it used to
What can I use instead?
@cupboy1

How is your base url defined in your config file?
It's blank in both config files (older version, and current version). Definitely a bug with the new codeignitor version. I don't know what older version I'm currently running but it's a version 3 version, just not the latest one. My IIS settings are correct.
Not a bug with either CodeIgniter or codeignitor:
https://www.codeigniter.com/user_guide/i...-not-empty
I was able to fix it by going into system/core/Config.php and changing __construct to do it the old way, using  $__SERVER['HTTP_HOST'] instead of the new, non-working way which used $__SERVER['SERVER_ADDR']

Hasn't been thoroughly tested yet but works so far.

Now that I've gotten a way into the site I get a new error:

Call to a member function unset_userdata() on null

Strange stuff.
Never a good idea to mess with code in system. The change was made because using HTTP_HOST can lead to a host header injection attack.

If you absolutely want to do it "your way", the proper approach would be to "extend" the Config class ... https://www.codeigniter.com/user_guide/g...core-class
I've taken a look at that. I intend to study it further.