Welcome Guest, Not a member yet? Register   Sign In
Message: Cannot modify header information - headers already sent by
#1

[eluser]bndk[/eluser]
Hey guys,

I'm currently creating a website where users will be able to browse the site in two different languages. If the user don't choose a language, I want a default language to be set.
The way I was thinking of doing this is to edit the Controller class' constructor like this using sessions:
Code:
if (!$this->session->userdata('language')) {
           $this->session->set_userdata('language', 'english');
            }
However, I get this error:
Quote:Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\some_site\system\core\Controller.php:57)

Filename: libraries/Session.php

Line Number: 672

I have two questions:
1. Why do I get the error?
2. Is my way of handling the default language-problem a good way do it? Please suggest other methods to do this.

Thanks!

#2

[eluser]skunkbad[/eluser]
You should search for the i18n library in the wiki. Your approach would not be good because Google and other spiders don't use cookies, and then can't index the other languages on your website. You would want them indexed, right?
#3

[eluser]bndk[/eluser]
[quote author="skunkbad" date="1333520487"]You should search for the i18n library in the wiki. Your approach would not be good because Google and other spiders don't use cookies, and then can't index the other languages on your website. You would want them indexed, right?[/quote]
Thanks for your reply!

I'll have a look at the i18n library.

I don't really understand what you mean by Google and spiders, though - why would this be of interest to me? What do you mean by indexed?

Thanks again.




Theme © iAndrew 2016 - Forum software by © MyBB