Firefox PHP

Docs doesn't say how templates are called?

Posted by tobefound 
Re: Docs doesn't say how templates are called?
February 03, 2010 08:51AM
@Maurice:

Thx, I have the user_restore_session hook working now! I'm sending some encrypted cookie data from my website to the module code for determining what user id to put in the session variable. A cleaner/safer solution would of course be to access the userid from the database but I haven't yet figured out how to externally access my Codeigniter session code. And I don't want to hard code a connection to the website's session table. Just seems ugly...

Another problem:

If there's no website user logged in for the moment then I simply set all the defined in the session array to NULL, but how can I tell phorum to redirect to my front page? I can probably do a redirect right in the user_session_restore function hook, but I'm thinking it's the wrong way as the incoming data should be returned (possibly modified). How to do this appropriately?

/T
Re: Docs doesn't say how templates are called?
February 03, 2010 08:59AM
So you want users to never access your forum when they are not logged in? You could use something like the common hook for that I guess. There you can do a redirect to your site and exit when no user is logged in.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Docs doesn't say how templates are called?
February 03, 2010 09:13AM
Great, thx.

Just curious, what happens if I do a redirect (calling the php header function) from within my user_restore_session hook? I tried it and it worked, but maybe the system complains quietly?

/T
Re: Docs doesn't say how templates are called?
February 03, 2010 09:15AM
Nope, that should work fine. Call exit after the redirect and it's optimized. It is not the most appropriate spot for it, but it certainly won't make some secret part of Phorum complain.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Docs doesn't say how templates are called?
February 04, 2010 04:28AM
I understand. But what happens with the broken hook chain? Isn't somebody waiting for my function to return the possible modified session data?

/T
Re: Docs doesn't say how templates are called?
February 04, 2010 04:42AM
Not somebody, maybe something. The hook system has called your hook, but will never get its return data. If you call exit in PHP, then PHP will exit. I don't see an issue with that.

Like I said, you can use a common hook for the task of redirecting, to keep your session restore hook cleaner. Whether or not to do this is up to the programmer's gut.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login