Forums | Mahara Community

Developers /
Cookie Issue and Help box issue


anonymous profile picture
Account deleted
Posts: 112

14 March 2010, 17:05

Hello everyone,

                      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.

anonymous profile picture
Account deleted
Posts: 228

15 March 2010, 16:50

Hi

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?

 

 

anonymous profile picture
Account deleted
Posts: 112

15 March 2010, 18:22

Hello Penny,

                   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.

Step One:

Created the subdomain.

Step Two: 

Created a index.php page for the subdomain that calls the appropiate files from the main domain.

Step Three:

Added the appropiate strings to lang/mahara.php.

Step Four:

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.  

anonymous profile picture
Account deleted
Posts: 228

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 ?

anonymous profile picture
Account deleted
Posts: 112

16 March 2010, 15:45

Hello Penny,

I will give you an example code.

The following is taken from the index.php from the subdomain.

<?php

define('INTERNAL', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
define('TITLE', get_string('learningcentertitle'));

$smarty = smarty();
$smarty->assign('PAGEHEADING', get_string('learningcenter'));
$smarty->display('/learn/index.tpl');
?>

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.

anonymous profile picture
Account deleted
Posts: 228

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 :)

anonymous profile picture
Account deleted
Posts: 112

16 March 2010, 19:12

Hello Penny,

                  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. Smile 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.

Cheers:)

7 results