• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 2.x Branch ‹ General Support (v2.x)
  • Change font size
  • FAQ
  • Register
  • Login

set login from client page

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
8 posts • Page 1 of 1

set login from client page

Postby Craig » Tue Oct 30, 2012 9:34 pm

Hi,

Is there any way to set the login name for the user using jquery, html or other client-side approach? I have used the hook to pass the username taken from a cookie in the config.local.php, but it seems to be inconsistent as quite often the user is not logged in. Also, I seem to end up with multiple logins of the same username.

Thanks,

Craig
Craig
Member
 
Posts: 14
Joined: Mon Oct 29, 2012 9:48 pm
Top

Re: set login from client page

Postby phpfreechat » Tue Oct 30, 2012 10:33 pm

I just twitted about hooks: https://twitter.com/phpfreechat/status/ ... 8925097985
pfc.before.auth hook can be used to provide the username to the chat from somewhere.

Try it.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Re: set login from client page

Postby phpfreechat » Tue Oct 30, 2012 10:34 pm

Have a look to the phpbb3 hook, it could help you too: https://github.com/kerphi/phpfreechat/t ... hpbb3-auth
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Re: set login from client page

Postby Craig » Tue Oct 30, 2012 11:14 pm

As the config lives outside the host application, it seems that I can only really use the cookie collection to get the current login to pass to the chat. For some reason, this ends up not working consistently and the user can get a blank screen. I think I will try using version 1.5 of that chat instead until 2.0 is a little more mature.

Thanks.
Craig
Member
 
Posts: 14
Joined: Mon Oct 29, 2012 9:48 pm
Top

Re: set login from client page

Postby phpfreechat » Wed Oct 31, 2012 11:24 am

Having your cookie outside the chat domain is not really a problem, you can connect authentication system using a ticket system. I gave you an example for phpbb3 but it can be extrapolated: https://github.com/kerphi/phpfreechat/b ... h/auth.php

This kind of integration require advanced PHP skills. Don't hesitate to contact our commercial support if you need a deep integration.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Re: set login from client page

Postby Craig » Wed Oct 31, 2012 2:54 pm

Yes, I got it working, but for some reason it is not consistent. Sometimes when the chat is loaded, no login happens and the user can't post. The problem may be with my host application, or it may be the chat, I don't know.

This is the content of my config.local.php:

Code: Select all
<?php
$GLOBALS['pfc_hooks']['pfc.before.auth'][5] = function ($app, $req, $res) {
  return function ($hr) use ($app, $req, $res) {
   $username = "";
   foreach($_COOKIE as $key => $value) {
      if(preg_match('@^wordpress_logged_in_@', $key)) {
         $cookie = explode('|', $_COOKIE[$key]);
         $username = $cookie[0];
      }
   }
    $hr->login = $username;
  };
};


I am trying to set up the version 1.5 chat instead as I can use the $params[] technique of setting the nick, which should be more reliable. I'd appreciate if you could look at my question at http://www.phpfreechat.net/forum/viewtopic.php?f=8&t=6051 about the 404 I am getting.
Craig
Member
 
Posts: 14
Joined: Mon Oct 29, 2012 9:48 pm
Top

Re: set login from client page

Postby phpfreechat » Wed Oct 31, 2012 4:55 pm

Craig wrote:Yes, I got it working, but for some reason it is not consistent. Sometimes when the chat is loaded, no login happens and the user can't post. The problem may be with my host application, or it may be the chat, I don't know.

You should have a look to your php error logs.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Re: set login from client page

Postby Craig » Fri Nov 16, 2012 9:54 pm

I implemented 1.5 in a wordpress template and the login works perfectly now.
Craig
Member
 
Posts: 14
Joined: Mon Oct 29, 2012 9:48 pm
Top


Post a reply
8 posts • Page 1 of 1

Return to General Support (v2.x)

Who is online

Users browsing this forum: No registered users and 2 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub