[pLog-svn] r4691 - plog/branches/lifetype-1.2/class/net/http/session
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Mon Feb 5 16:39:31 EST 2007
Author: oscar
Date: 2007-02-05 16:39:30 -0500 (Mon, 05 Feb 2007)
New Revision: 4691
Modified:
plog/branches/lifetype-1.2/class/net/http/session/sessionmanager.class.php
Log:
This should solve the issue regarding multiple cookies and the autodetection of the user currently logged in via the comment form, as HttpVars::getBaseUrl() was returning different values depending on whether it was being called from index.php or blog.php. The result of this method for index.php was "/" while for blog.php, which gets included when using URLs such as /blog/my-blog/2007/02/05/my-post, was something like /blog/my-blog/2007/02/05. When browsing a permalink, first of all a new cookie was being created all the time and second, the wrong one was being sent. Sorry, it's a bit difficult to describe :)
I've also fixed SessionManager::setSessionCookieDomain() so that it sets the cookie for the whole domain "domain.com" instead of only "www.domain.com", or else it wouldn't work when subdomains are turned on.
Modified: plog/branches/lifetype-1.2/class/net/http/session/sessionmanager.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/net/http/session/sessionmanager.class.php 2007-02-04 15:57:09 UTC (rev 4690)
+++ plog/branches/lifetype-1.2/class/net/http/session/sessionmanager.class.php 2007-02-05 21:39:30 UTC (rev 4691)
@@ -37,6 +37,7 @@
// this needs to be done before the session is started
$sessionPath = SessionManager::setSessionCookiePath();
+ //$sessionPath = "/";
$sessionDomain = SessionManager::setSessionCookieDomain();
session_cache_limiter( "" );
@@ -70,15 +71,19 @@
* @return nothing
*/
function setSessionCookiePath()
- {
- // get the right url for the script... somehow $_SERVER["REQUEST_URI"]
- // is returning things like "http://83.102.183.10.in-addr.arpa/plog/test.php"
- // in my case which are correct but probably not what we're expecting!
- $scriptUrl = HttpVars::getBaseUrl();
+ {
+ // get the current base url and fetch it dynamically according to the values
+ // returned by Apache/PHP if not set yet in the config settings
+ $config =& Config::getConfig();
+ $scriptUrl = $config->getValue( "base_url" );
+ if( $scriptUrl == "" )
+ $scriptUrl = HttpVars::getBaseUrl();
+
$url = new Url( $scriptUrl );
$path = dirname($url->getPath());
+
if( $path == "" || $path == "\\" )
- $path = "/";
+ $path = "/";
return $path;
}
@@ -91,15 +96,21 @@
*/
function setSessionCookieDomain()
{
- $scriptUrl = HttpVars::getBaseUrl();
+ // get the current base url and fetch it dynamically according to the values
+ // returned by Apache/PHP if not set yet in the config settings
+ $config =& Config::getConfig();
+ $scriptUrl = $config->getValue( "base_url" );
+ if( $scriptUrl == "" )
+ $scriptUrl = HttpVars::getBaseUrl();
+
$url = new Url( $scriptUrl );
- $domain = $url->getHost();
+ $domain = str_replace( "www.", ".", $url->getHost());
// this won't work for top level domains and domains such as
// 'localhost' or internal domains for obvious security reasons...
// See comments in http://fi.php.net/manual/en/function.session-set-cookie-params.php
if( count(explode('.', $domain)) > 1 ) {
- return $domain;
+ return $domain;
}
}
More information about the pLog-svn
mailing list