Welcome Guest, Not a member yet? Register   Sign In
Problems with the native session
#11

[eluser]Thorpe Obazee[/eluser]
<snipped>
#12

[eluser]TheFuzzy0ne[/eluser]
I think you're going to have problems using CodeIgniter sessions and native sessions. I seem to recall the two don't play nicely together. The CodeIgniter session class uses session_start(), so calling it a second time shouldn't be necessary. I'd suggest that you use a version of the session library that made for working with native sessions only - http://codeigniter.com/wiki/Native_session/.
#13

[eluser]Zorancho[/eluser]
Yes that was the problem, i am so silly... I am nearly done with the project and i am using only the native session, i am still beginner with CI, so i still rely on php native stuff. But on my next project i will take in consideration using CI Session library. Thank you all for being helpful, i appreciate it. I was stuck for months trying to learn CakePHP and all i was getting was nights without sleep and trying to figure out how things work. Using CI i learned a lot about php itself, i am using the user guide and learning from the core code as well. When i have time i will do a translation of CI documentation in Macedonian. Thanks again guys, i really didn't expect so many answers.Smile
#14

[eluser]TheFuzzy0ne[/eluser]
The CI session library couldn't be any easier if it tried.
Code:
$this->session->set_userdata('some_key', 'some_value'); # Sets userdata.
$this->session->userdata('some_key'); # Returns the userdata wih the specified key.
$this->session->unset_userdata('some_key'); # Unsets the userdata.
$this->session->all_userdata(); # Retrieves the entire userdata array.

That's pretty much all you need to know. Then there's flashdata:
Code:
$this->session->set_flashdata('some_key', 'some_value'); # Set data to be available on the next request only.
$this->session->keep_flashdata('some_key'); # Extends the lifespan by one request.

The library has been made to make things easier for you. One of the best things I love about this, is that I can do something like this:

Code:
$data = $this->session->userdata('value_that_doesnt_exist');

And if it doesn't exist, FALSE will be returned. Doing the same thing with native sessions would result in a PHP notice unless you did this:

Code:
$data = (isset($_SESSION['value_that_doesnt_exist']) ? $_SESSION['value_that_doesnt_exist'] : FALSE;

I think it's clear which one is better here. Smile
#15

[eluser]TheFuzzy0ne[/eluser]
[quote author="bargainph" date="1242891772"]<snipped>[/quote]

Aw, poor doggy...




Theme © iAndrew 2016 - Forum software by © MyBB