Welcome Guest, Not a member yet? Register   Sign In
Using sessions in loader.php?
#1

[eluser]P.T.[/eluser]
Hello all,

First of all, thanks for the wonderfull framework!
I am still learning the framework, but it works really nice Smile

Now, i got a question. I created my own way to handle language files. I save the language in a session called 'language'.

Now i want that session to be loaded in the loader.php file where the standard language files are autoloaded.

Since languages files are loaded before libraries, I cut the language loading part and placed it right below the libraries loading part.

Code:
// Load all other libraries
            foreach ($autoload['libraries'] as $item)
            {
                $this->library($item);
            }

if (isset($autoload['language']) AND count($autoload['language']) > 0)
            {
                   //log_message("DEBUG", "Loading language files...");
                    $this->language($autoload['language'], 'english');
            }

'english' should be replaced here with the language session.
I tried something like this:

$language = MY_Session::userdata('language');

But I retrieve an empty / false variable.
But if I am correct, the sessions are already loaded and ready for use.

Any idea what I am doing wrong or any idea how I could fix this? Or am i doing something stupid?

(By the way, i know that their is a standard language thingy around. Which adds something to your URL, but that's not what we want.)
#2

[eluser]Jamie Rumbelow[/eluser]
Try putting the code to check for the session and load the language file in a controller, then inherit every other controller from that one.

This also works for things like authorisavion.
#3

[eluser]P.T.[/eluser]
Sometimes, things look so difficult but are yet so easy.

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB