Welcome Guest, Not a member yet? Register   Sign In
Session and subdomain issue
#1

[eluser]Christophe28[/eluser]
Hello,

Today I'm trying to get my website work in two languages. English for www.domain.com and Dutch for nl.domain.com. It all works fine Smile

Just forgot one thing ... when you are logged in at www.domain.com, change your view to nl.domain.com, you are logged out again :-(

How can you get arround this issue? Use fake subdomains?

Please help me Smile

Christophe
#2

[eluser]philm[/eluser]
Quote:The domain that the cookie is available. To make the cookie available on all subdomains of example.com then you'd set it to '.example.com'. The . is not required but makes it compatible with more browsers. Setting it to www.example.com will make the cookie only available in the www subdomain. Refer to tail matching in the ยป spec for details.

http://php.net/manual/en/function.setcookie.php

It's not something I've had to deal with in CI specifically, maybe somebody else has...
#3

[eluser]Christophe28[/eluser]
Hi,

Thank you for your reply.

I tried yesterday to set $config['cookie_domain'] to ".domain.com", but that didn't work. Every page refresh CodeIgniter started a new session. However, I have found the problem. I forgot to delete all cookies in the webbrowser before changing and testing (didn't know that was necessery) Also I have deleted all sessions in the database and now it works! Thanks mate! Smile

Christophe
#4

[eluser]CodeMagician[/eluser]
My personal solution was to force the site to run without the "www". That way I knew it would work all the time. Eliminating the need for extensive testing.

I added this code to the top of my /config/config.php file. From line 2, place under BASEPATH security check that's found in line 1.

Code:
/* Remove www */
if(strpos($_SERVER['HTTP_HOST'],'www.')!==false) {
    $url = 'http://mydomain.com.au'.$_SERVER['REQUEST_URI'];
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: '.$url);
    exit();
}
#5

[eluser]Christophe28[/eluser]
Hello,

But I really need different URL's for different languages. Now Dutch is nl.domain.com, French is fr.domain.com, English is www.domain.com

It would work, but what to do with the search engines which really need different url's for different languages. ;-)

Christophe
#6

[eluser]CodeMagician[/eluser]
Interesting, in that case...
Here's an idea:
detect the subdomain using similar method to above, set a Userdata or Session variable to define the "language". Language setting could be a DB table name, a filename, or maybe a /views/folder-name that holds all templates for that language.

Once it's all set, just redirect them to http://domain.com/ (the language settings will be saved in Userdata or Session. The main site should detect the language and proceed as normal.

* make sure the userdata is being saved across all subdomains, see config file setting. eg. ".domain.com" (remove first dot)

Sound good?
#7

[eluser]CodeMagician[/eluser]
[quote author="Christophe28" date="1280971961"]Hello,
Just forgot one thing ... when you are logged in at www.domain.com, change your view to nl.domain.com, you are logged out again :-(

How can you get arround this issue? Use fake subdomains?
[/quote]

I've read that you can avoid this issue by adjusting a variable in config.php file.

Code:
$config['cookie_domain']    = "domain.com"; // Set to .your-domain.com for site-wide cookies

Sessions are kept in cookies, so it should work Undecided
#8

[eluser]Clooner[/eluser]
http://ellislab.com/forums/viewthread/157468/
#9

[eluser]Christophe28[/eluser]
Hello,

Thank you for all your kind responses but like you can ready in my message posted on 05 August 2010 11:05 AM, it already works ;-)

Best,
Christophe




Theme © iAndrew 2016 - Forum software by © MyBB