<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0'>
	<channel>
		<title>cotonti.com : auto-logged out if using url_rewrite and not checking &quot;remember me&quot; box</title>
		<link>https://www.cotonti.com</link>
		<description>Last topic posts</description>
		<generator>Cotonti</generator>
		<language>en</language>
		<pubDate>Sun, 05 Apr 2026 16:35:34 -0000</pubDate>

		<item>
			<title>Trustmaster</title>
			<description><![CDATA[Sorry, I've missed this message. No, random number (like sed_unique) won't work because it changes every request. The 'alphanumericalstring' seems like what I really meant. Yes, PHP sessions are tied to the same domain by default so you need to change php.ini to make it support subdomains... or enforce &quot;remember me&quot; like you did.]]></description>
			<pubDate>Thu, 01 Jul 2010 15:10:23 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/forums?m=posts&q=5657&d=0#post25124]]></link>
		</item>
		<item>
			<title>donP</title>
			<description><![CDATA[No, I'm not at my work-PC till this night... I'll try as soon as possible. Thank you.<br />
<br />
<strong>P.S.</strong> Do you suggest me to use a random-value-generator function? Do you know some?<br />
<strong>P.S.2</strong> I'd remember you that many other parts of Cotonti Code have to be changed in my case (using mod_rewrite to create subdomauins)... all SED_ABSOLUTE_ULR codes at first...<br />
<br />
<strong>Added 1 day later:</strong><br />
<br />
I've tried, following your suggestions...<br />
<br />
I first used<br />
<br />
<div class="highlight"><pre class="php">$site_id = 'ct' . sed_unique(16);</pre></div>
<br />
but I couldn't login at all, no more.<br />
<br />
Then I tried<br />
<br />
<div class="highlight"><pre class="php">$site_id = 'alphanumericalstring';</pre></div>
<br />
and the problem was the same I described in the first post of this topic... so, it would be the PHPSESSID cookie and its domain (but I can't figure how it can function now simply by permanently checking the &quot;remember me&quot; checkbox... but it work well, and I use this solution for now).]]></description>
			<pubDate>Mon, 07 Jun 2010 15:45:05 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/forums?m=posts&q=5657&d=0#post24893]]></link>
		</item>
		<item>
			<title>Trustmaster</title>
			<description><![CDATA[You're right, currently subdomain authentication is not supported because of site_id. You can manually fix it like<br />
<div class="highlight"><pre class="php">$site_id = 'ctSomeRandomThingHere';</pre></div>
In Siena it will be possible to set site_id in config.php with $cfg['site_id'] for sites with subdomains.<br /><br /><b>Added 3 days later:</b><br /><br />Have you tried this solution? If it doesn't work then I think the reason might be PHPSESSID cookie and its domain.]]></description>
			<pubDate>Fri, 04 Jun 2010 13:51:14 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/forums?m=posts&q=5657&d=0#post24847]]></link>
		</item>
		<item>
			<title>donP</title>
			<description><![CDATA[From when I realized my own url_rewrite transformation to obtain &quot;fake&quot; subdomains (cat1.mydomain.net/subcat... cat2.mydomain.net/subcat/subsubcat...) I had much problems in stay logged in.<br />
In fact, everytime I surfed from www.mydomain.net to one of the subdomains I got logged-out (and when I returned to the same location but with normal ulr (e.g. www.mydomain.net/list.php?c=cat1) I was magically still logged-in.<br />
<br />
<span style="color:#A40000"><strong>I think I've found the problem...</strong></span><br />
<br />
In <strong>system/common.php</strong> we have:<br />
<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;

session_start();

if(!empty($_COOKIE&#091;$site_id&#093;) || !empty($_SESSION&#091;$site_id&#093;))
{
	$u = empty($_SESSION&#091;$site_id&#093;) ? base64_decode($_COOKIE&#091;$site_id&#093;) : base64_decode($_SESSION&#091;$site_id&#093;);
	$u = explode(':_:', $u);
	$u_id = (int) sed_import($u&#091;0&#093;, 'D', 'INT');
	$u_passhash = sed_import($u&#091;1&#093;, 'D', 'ALP');
	if($u_id &gt; 0)
	{
</pre></div>
<br />
As you can clearly see, the value of <strong>$sys['site_id']</strong> (used to create log-session-cookie) is derived from <strong>$cfg['mainurl']</strong>... obviously, a url with a subdomain format doesn't match with this cookie... so, the user is seen as logged-out when we have a subdomain in url but not when we write the corresponding (original) ulr for that location.<br />
<br />
For now, the only solution I've found is always checking the &quot;Remember me&quot; checkbox when loggin-in (I don't know how this trick interacts with session-coockie-creation...<br />
I had to core-hack  <strong>system/header.php</strong> changing this line:<br />
<div class="highlight"><pre class="php">$out&#091;'guest_cookiettl'&#093; = '&lt;input type=&quot;checkbox&quot; name=&quot;rremember&quot; /&gt;';</pre></div>
like that:<br />
<div class="highlight"><pre class="php">$out&#091;'guest_cookiettl'&#093; = '&lt;input type=&quot;checkbox&quot; checked=&quot;yes&quot; name=&quot;rremember&quot; style=&quot; visibility: hidden; &quot; /&gt;';</pre></div>
to set always checked that box and not to permit users to un-check...<br />
<br />
I hope Developers could find a solution with newer auth_session methods...]]></description>
			<pubDate>Fri, 04 Jun 2010 07:16:20 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/forums?m=posts&q=5657&d=0#post24843]]></link>
		</item>
	</channel>
</rss>