Welcome Guest, Not a member yet? Register   Sign In
$session
#1

[eluser]GI-Joe[/eluser]
Can I use session created in one controller in another controller.

say in Controller A
Code:
$this->session->set_userdata('data','somedata');

Can I use it in another controller

Controller B

Code:
echo $this->session->userdata('data');
#2

[eluser]InsiteFX[/eluser]
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.
#3

[eluser]Otemu[/eluser]
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.
#4

[eluser]GI-Joe[/eluser]
Code:
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
#5

[eluser]GI-Joe[/eluser]
How to get session data in constructor?
#6

[eluser]InsiteFX[/eluser]
Autoload the session library in ./application/config/autoload.php
#7

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




Theme © iAndrew 2016 - Forum software by © MyBB