FreiChat related discussions
User Authentification does not work correctly

This is the session.php from my community where I have added Freichat. But users always be logged in as guest. The user session gives me the correct user id. I cannot find what is wrong.

<!--===========================Community=======START=========================-->
<?php $session_uid=$_SESSION['uid'];
// Session Private
if(!empty($session_uid))
{
$uid=$session_uid;
$login='1';
}
else if($_GET['username'] || $_GET['msgID'])
{
$uid=$Wall->User_ID($username);
$login='0';
}
else
{
$url=$base_url.'login.php';
header("location:$url");
}

?>
<!--===========================Community=======END=========================-->



<!--===========================FreiChat=======START=========================-->
<!-- For uninstalling ME , first remove/comment all FreiChat related code i.e below code
Then remove FreiChat tables frei_session & frei_chat if necessary
The best/recommended way is using the module for installation -->

<?php $ses = null; // Return null if user is not logged in

if(isset($_SESSION['uid']))
{
if($_SESSION['uid'] != null) // Here null is guest
{
$ses=$_SESSION['uid']; //LOOK, now userid will be passed to FreiChat
setcookie("freichat_user", "LOGGED_IN", time()+3600, "/"); // *do not change -> freichat code


echo '<script type="text/javascript">alert("' . $ses . '")</script>';

} else {
$ses = null;
setcookie("freichat_user", null, time()+3600, "/"); // *do not change -> freichat code
}
}

if(!function_exists("freichatx_get_hash")){
function freichatx_get_hash($ses){

if(is_file("/websitename/httpd.www/freichat/hardcode.php")){

require "/websitename/httpd.www/freichat/hardcode.php";

$temp_id = $ses . $uid;

return md5($temp_id);

}
else
{
echo "<script>alert('module freichatx says: hardcode.php file not
found!');</script>";
}

return 0;
}
}
?>
<script type="text/javascript" language="javascipt" src=".../freichat/client/main.php?id=&lt;?php%20echo%20%24ses;?&gt;&amp;xhash=&lt;?php%20echo%20freichatx_get_hash(%24ses);%20?&gt;"></script><link rel="stylesheet" href=".../freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css"><!--===========================FreiChatX=======END=========================-->

This is the session.php from my community where I have added Freichat. But users always be logged in as guest. The user session gives me the correct user id. I cannot find what is wrong. &amp;lt;!--===========================Community=======START=========================--&amp;gt; &amp;lt;?php $session_uid=$_SESSION[&#039;uid&#039;]; // Session Private if(!empty($session_uid)) { $uid=$session_uid; $login=&#039;1&#039;; } else if($_GET[&#039;username&#039;] || $_GET[&#039;msgID&#039;]) { $uid=$Wall-&amp;gt;User_ID($username); $login=&#039;0&#039;; } else { $url=$base_url.&#039;login.php&#039;; header(&quot;location:$url&quot;); } ?&amp;gt; &amp;lt;!--===========================Community=======END=========================--&amp;gt; &amp;lt;!--===========================FreiChat=======START=========================--&amp;gt; &amp;lt;!-- For uninstalling ME , first remove/comment all FreiChat related code i.e below code Then remove FreiChat tables frei_session &amp; frei_chat if necessary The best/recommended way is using the module for installation --&amp;gt; &amp;lt;?php $ses = null; // Return null if user is not logged in if(isset($_SESSION[&#039;uid&#039;])) { if($_SESSION[&#039;uid&#039;] != null) // Here null is guest { $ses=$_SESSION[&#039;uid&#039;]; //LOOK, now userid will be passed to FreiChat setcookie(&quot;freichat_user&quot;, &quot;LOGGED_IN&quot;, time()+3600, &quot;/&quot;); // *do not change -&amp;gt; freichat code echo &#039;&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;alert(&quot;&#039; . $ses . &#039;&quot;)&amp;lt;/script&amp;gt;&#039;; } else { $ses = null; setcookie(&quot;freichat_user&quot;, null, time()+3600, &quot;/&quot;); // *do not change -&amp;gt; freichat code } } if(!function_exists(&quot;freichatx_get_hash&quot;)){ function freichatx_get_hash($ses){ if(is_file(&quot;/websitename/httpd.www/freichat/hardcode.php&quot;)){ require &quot;/websitename/httpd.www/freichat/hardcode.php&quot;; $temp_id = $ses . $uid; return md5($temp_id); } else { echo &quot;&amp;lt;script&amp;gt;alert(&#039;module freichatx says: hardcode.php file not found!&#039;);&amp;lt;/script&amp;gt;&quot;; } return 0; } } ?&amp;gt; &amp;lt;script type=&quot;text/javascript&quot; language=&quot;javascipt&quot; src=&quot;.../freichat/client/main.php?id=&amp;lt;?php echo $ses;?&amp;gt;&amp;xhash=&amp;lt;?php echo freichatx_get_hash($ses); ?&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;.../freichat/client/jquery/freichat_themes/freichatcss.php&quot; type=&quot;text/css&quot;&amp;gt; &amp;lt;!--===========================FreiChatX=======END=========================--&amp;gt;

In your website source , can you see the user's id ?

You should find it on this line

freichat/client/main.php?id=YOUR_USER_ID

In your website source , can you see the user&#039;s id ? You should find it on this line &amp;lt;code&amp;gt;freichat/client/main.php?id=YOUR_USER_ID&amp;lt;/code&amp;gt;
Necessity is the mother of all inventions!
125
1
0
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft