CodeIgniter会话userdata不显示ip地址/ session_id等

I am building a small e-commerce website, and I am trying to implement an add-to-cart feature without asking the user to log in or register. This gets me thinking about creating a database and saving cart items associated with a certain ip address to this database.

However, when I try to var_dump($this->session->all_userdata( )), it doesn't return the expected array containing session_id, ip_address etc. Up until this point I have used session userdata without any problem so I'm not sure what's going on.

Could someone please help me fix this issue?

That you don't see session_id, ip_address, user_agent and last_activity in the "userdata" is (I assume) because you're now using CodeIgniter 3, which no longer stores them as part of the session data.
If you really need to access these pieces of metadata, there's already a dedicated section of the manual for that:

http://www.codeigniter.com/userguide3/libraries/sessions.html#accessing-session-metadata

However, you should NOT associate "carts" with IP addresses. It's not a good solution for the problem, not a secure one and you don't need to do it in the first place.
Sessions alone are perfectly sufficient for what you're trying to do - just store the shopping carts' contents as session data and that's it! Every user has a unique session, you don't need to worry about that.