CodeIgniter Forums
2 different sessions at the same time - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: 2 different sessions at the same time (/showthread.php?tid=26112)



2 different sessions at the same time - El Forum - 01-06-2010

[eluser]rijobo[/eluser]
Hello,

I'm using a session for my shopping cart and a session for my log in system for the customers.
When I try to use the session variables of my shopping cart I get this message:

Message: Undefined variable: _SESSION

is it possible to use 2 sessions at the same time?


2 different sessions at the same time - El Forum - 01-06-2010

[eluser]Colin Williams[/eluser]
It's the same session, just different data. For instance, an user with a cart but not logged in simply wouldn't have a valid logged in flag in the session, but they would have a cart id.

Also, if you're using the Session class provided by CI, there is no reason to access $_SESSION. If you aren't using CI's Session class, be sure you've started the session first


2 different sessions at the same time - El Forum - 01-06-2010

[eluser]rijobo[/eluser]
But then why does it say undefined variable?
Before I implemented my login system, I didn't get this error.


2 different sessions at the same time - El Forum - 01-06-2010

[eluser]Colin Williams[/eluser]
You want me to comment on code I can't see?


2 different sessions at the same time - El Forum - 01-06-2010

[eluser]rijobo[/eluser]
You're right, I'm sorry.

I've already found what I did wrong. I forgot my session_start().