Forums | Mahara Community
Cookie Issue and Help box issue
14 March 2010, 17:05
If this has been posted somewhere kindly point me in the right direction. We added a learning center that will help members to understand and how to use the site. However, it's on a subdomain and when they log out and return to the subdomain it's telling that user they're still logged in. How do we get the cookies to work for this? Also the help icon boxs say an error occurred when clicked on, is there something we have to configure in another file for this to work? Also do we have to configure mahara to run on a subdomain as well as the main domain name? Thanks for your help.
15 March 2010, 16:50
It sounds like you want to have an integration with a separate application - that's generally a bit more complicated than mucking with cookies (although you *can*).
What exactly are you trying to do? You have two separate applications, one is Mahara, and it's running on the subdomain, and the other one is running on the main domain?
Which one contains the database that can authenticate users?
15 March 2010, 18:22
It's not an application at all. Let me see if I can explain this without getting you lost. I will just list the steps that we took when we added a page to the subdomain.
Created the subdomain.
Created a index.php page for the subdomain that calls the appropiate files from the main domain.
Added the appropiate strings to lang/mahara.php.
Added the content templates to raw/templates/learn/
That's all we did to create the subdomain. It worked like a charm until we realized that the cookies aren't working properly. We tested to see if it would show the user who was logged in and it does. When the user logs out from any part of the site and returns to learn.chatterbing.com they are shown as logged in.
I was thinking if there was a way to add the subdomain to mahara then that might solve the issue. Honestly though I am not sure.
16 March 2010, 2:59
Hrm, that's a bit hard to debug unless maybe you send some code to look at.
What if you do a hard refresh ? Could it just be cache?
Are you testing for the mahara cookie directly and displaying information, or are you just letting the files you call from mahara (i assume when you say call you mean include at the php level) print login information directly ?
16 March 2010, 15:45
I will give you an example code.
The following is taken from the index.php from the subdomain.
require(dirname(dirname(__FILE__)) . '/init.php');
$smarty = smarty();
Now the above code worked fine to display the information on the subdomain. But, when a user is logged in and they click the link to send them to the learning subdomain they are required to log in. When they log out and return to the learning center they are shown logged in. The only way to get the user shown logged out is by clearing the browsers cookies.
I am not sure what else I could include in the php file to get the cookies to work properly.
Thanks for your reply.
16 March 2010, 17:15
oh sorry I misunderstood. You are actually hitting the mahara login url ont he subdomain, not redirecting to the real application domain to log in and then back again.
We're just talked about adding a cookie domain config setting, which would help you. What you want to do is called tail matching - you set the cookie domain to .yourdomain.com (note the . at the start). Try putting a ini_set('session.cookie_domain', '.url.com') somewhere (like config.php) and report back :)
16 March 2010, 19:12
That actually worked. I had tried something very similar to that and I guess I had the coding wrong because, I couldn't get it to work to save my life. I actually had init_set('cookie_domain','url.com') and if you notice I had a few mistakes.
Sometimes I have no clue how I come to these lines of code. I think I just try to write this stuff too fast and I really should double check my work. So, I honestly didn't think that would work. Well, thanks for helping me find my mistake on that one. And again thanks for the awesome support.