<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0'>
	<channel>
		<title>cotonti.com : Auth System</title>
		<link>https://www.cotonti.com</link>
		<description>Neueste Themenbeiträge</description>
		<generator>Cotonti</generator>
		<language>en</language>
		<pubDate>Sat, 11 Apr 2026 21:29:43 -0000</pubDate>

		<item>
			<title>Trustmaster</title>
			<description><![CDATA[The $_SESSION['cot_user_id'] variable will available in 0.6.7.]]></description>
			<pubDate>Mo, 01 Mär 2010 23:10:23 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/de/forums?m=posts&q=5339&d=0#post23310]]></link>
		</item>
		<item>
			<title>scriptor</title>
			<description><![CDATA[okay the i wait <img class="aux smiley" src="https://www.cotonti.com/./images/smilies/smile.gif" alt=":)" /> because this script cant give me my user id when i´m logged in <img class="aux smiley" src="https://www.cotonti.com/./images/smilies/sad.gif" alt=":(" />]]></description>
			<pubDate>Mo, 01 Mär 2010 17:36:53 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/de/forums?m=posts&q=5339&d=0#post23304]]></link>
		</item>
		<item>
			<title>Trustmaster</title>
			<description><![CDATA[<blockquote><a href="https://www.cotonti.com/forums.php?m=posts&amp;p=23162#23162">#</a> <strong>scriptor :</strong>
How to find the user id of an active session with an external script that don´t use the Cotonti Function?<br />
</blockquote>
This method is not very secure and can be faked with a cookie, but I'll explain it. First you need to get $cfg['mainurl'] from Cotonti's <em>datas/config.php</em>. Then you can get the user ID like this:<br />
<div class="highlight"><pre class="php">$site_id = 'ct' . substr(md5($cfg&#091;'mainurl'&#093;), 0, 10);
if (!empty($_COOKIE&#091;$site_id&#093;)) $u_data = $_COOKIE&#091;$site_id&#093;;
elseif (!empty($_SESSION&#091;$site_id&#093;)) $u_data = $_SESSION&#091;$site_id&#093;;
else $u_data = false;

if ($u_data)
{
  // Get Cotonti user ID
  $u_data = explode(':_:', base64_decode($u_data));
  $cot_user_id = $u_data&#091;0&#093;;
}
else
{
  // Not logged in
}</pre></div>
<br />
In Cotonti Siena there will be a session variable to get that ID in a more easy and reliable way.]]></description>
			<pubDate>So, 28 Feb 2010 20:54:59 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/de/forums?m=posts&q=5339&d=0#post23273]]></link>
		</item>
		<item>
			<title>GHengeveld</title>
			<description><![CDATA[Interesting read, thanks for that Trustmaster.]]></description>
			<pubDate>So, 28 Feb 2010 05:37:08 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/de/forums?m=posts&q=5339&d=0#post23254]]></link>
		</item>
		<item>
			<title>scriptor</title>
			<description><![CDATA[How to find the user id of an active session with an external script that don´t use the Cotonti Function?]]></description>
			<pubDate>Di, 23 Feb 2010 19:26:29 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/de/forums?m=posts&q=5339&d=0#post23162]]></link>
		</item>
		<item>
			<title>Trustmaster</title>
			<description><![CDATA[Yes, the authentication system is a bit complicated. The actual authenticating code (that checks user auth keys) is located in <em>system/common.php</em> at <em>lines 201-311</em>.<br />
<br />
Here is a brief explanation of how it works.<br />
<br />
First you login via users.php?m=auth. That script checks your username and password. If the login is successful, it creates the authentication keys, which consist of:<br />
<ul>
<li><strong>User ID</strong></li>
<li><strong>Password Hash</strong>. This is not just and MD5 hash of the password. It is actually<br />
<div class="highlight"><pre class="php">$passhash = md5($rmdpass.$hashsalt);</pre></div>
where $rmdpass is an MD5 hash of the password and $<strong>hashsalt</strong> is a random string that does not let an attacker to get a collision for your password if he has got the $passhash from your cookie</li>
</ul>
If you have chosen &quot;remember me&quot;, authentication keys will be saved in cookie variable, otherwise a session variable is used. Variable name is $sys['site_id'], so it's unique for every site:<br />
<div class="highlight"><pre class="php">$site_id = 'ct' . substr(md5($cfg&#091;'mainurl'&#093;), 0, 10);
$sys&#091;'site_id'&#093; = $site_id;</pre></div>
<br />
Putting all together, the auth keys are remembered like this:<br />
<div class="highlight"><pre class="php">$passhash = md5($rmdpass.$hashsalt);
$u = base64_encode($ruserid.':_:'.$passhash);

if($rremember)
{
	sed_setcookie($sys&#091;'site_id'&#093;, $u, time()+$cfg&#091;'cookielifetime'&#093;, $cfg&#091;'cookiepath'&#093;, $cfg&#091;'cookiedomain'&#093;, $sys&#091;'secure'&#093;, true);
}
else
{
	$_SESSION&#091;$sys&#091;'site_id'&#093;&#093; = $u;
}</pre></div>
<br />
Then goes another trick against client side request forgery: the <strong>hashsalt</strong> is changed every minute. To be more correct, there is a session variable that indicates when the hashsalt was last changed:<br />
<div class="highlight"><pre class="php">$_SESSION&#091;'saltstamp'&#093; = $sys&#091;'now_offset'&#093;;</pre></div>
If $_SESSION['saltstamp'] is older than 1 minute, the hashsalt is changed during the request. It is changed both in user cookie/session and is also tracked in <em>sed_users</em> table in the column called <em>user_hashsalt</em>.]]></description>
			<pubDate>Di, 23 Feb 2010 16:57:07 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/de/forums?m=posts&q=5339&d=0#post23160]]></link>
		</item>
		<item>
			<title>scriptor</title>
			<description><![CDATA[I want to know how the auth system from Cotonti works? Some scripts from seditio dont work with cotonti ans so i want to know how to request the user id and so]]></description>
			<pubDate>Di, 23 Feb 2010 00:50:59 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/de/forums?m=posts&q=5339&d=0#post23139]]></link>
		</item>
	</channel>
</rss>