Welcome Guest, Not a member yet? Register   Sign In

Can I use session created in one controller in another controller.

say in Controller A

Can I use it in another controller

Controller B

echo $this->session->userdata('data');

Yes the sessions are global to your application. But if you need to access them from a library then you need to use the CodeIgniter Super Object.

Yes check out the session class

Quote:The Session class permits you maintain a user's "state" and track their activity while they browse your site.

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Admin::$session

Filename: controllers/admin.php

Line Number: 19

Fatal error: Call to a member function userdata() on a non-object in F:\xampp\htdocs\web\application\controllers\admin.php on line 19

Getting this error

How to get session data in constructor?

Autoload the session library in ./application/config/autoload.php

[quote author="InsiteFX" date="1339225230"]Autoload the session library in ./application/config/autoload.php
I have done that still can't get session data in constructor

Theme © iAndrew 2016 - Forum software by © MyBB