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

[eluser]vmuser[/eluser]
Hi!
Can i share a session between two different controllers? One set a value and the other retrieve the value. If yes, how can i do that ? If i can, i don't want store session in database.
At now i only tried to access to the global $CI object, but i can't get any values:


Code:
$CI = & get_instance();
return $CI->session->userdata('token');

Many thanks!
#2

[eluser]jedd[/eluser]
Hi vmuser, and welcome to the CI forums.

If you're using the session library - and loading it automatically in your config/autoload.php file - then you don't need to do the CI =& get_instance() thing. You only need to do that if you're wanting to talk to the super-object from outside a controller. Such as, for example, in a helper.

So, if you are trying to get session data from two different controllers, as you suggest, then it should just work. There's no obligation to store any of this data in a database, if you don't want to.

Try setting some data with a call like this:
Code:
$this->session->set_userdata('bob', 'says hello');

And recovering it in a different controller:
Code:
echo $this->session->userdata('bob');
#3

[eluser]vmuser[/eluser]
I must share the session between a controller and a soap client, but this it doesn't give me back the session probably because it can't set a cookie. How can i do?

Many thanks!
#4

[eluser]vmuser[/eluser]
Anybody can help me ? :-(
#5

[eluser]Dam1an[/eluser]
If you can't create a cookie, then it's a browser permission issue
Make sure you allow your browser to create cookied for your domain

The other alternative is to use native PHP session instead
#6

[eluser]TheFuzzy0ne[/eluser]
It might be worth seeing what happens if you use the session class with the SOAP client. It might require some modification, and it might not work at all, but if you can get it working, I think this will solve your problem.
#7

[eluser]vmuser[/eluser]
[quote author="Dam1an" date="1245078833"]The other alternative is to use native PHP session instead[/quote]

In both case (with native or CI sessions) i must track and report the cookie session; and if i use object serialization?




Theme © iAndrew 2016 - Forum software by © MyBB