Skip to content

Commit

Permalink
update auth cookie functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
zegenie committed Oct 5, 2012
1 parent 773c0b5 commit 2e03b9a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
5 changes: 4 additions & 1 deletion application/configuration/caspar.yml.template
@@ -1,14 +1,17 @@
# Caspar configuration

core:
base_url: "http://caspar.l"
base_url: "caspar.l"
base_path: "/"
cookie_domain: "caspar.l"
cookie_path: "/"
modules: ['main', 'b2db']
language: 'en_US'
debug: true
site_name: 'Caspar sample application'
stylesheets: []
javascripts: ['prototype', 'scriptaculous']
salt: 5DsIFX9SrMloZxvUnhdpZC
user_classname: \caspar\core\User
response_classname: \caspar\core\Response

Expand Down
20 changes: 20 additions & 0 deletions caspar/core/Caspar.class.php
Expand Up @@ -265,6 +265,26 @@ public static function getBaseURL()
return self::$_configuration['core']['base_url'];
}

/**
* Get the cookie domain
*
* @return string
*/
public static function getDefaultCookieDomain()
{
return self::$_configuration['core']['cookie_domain'];
}

/**
* Get the cookie base path
*
* @return string
*/
public static function getDefaultCookiePath()
{
return self::$_configuration['core']['cookie_path'];
}

/**
* Get the subdirectory part of the url
*
Expand Down
6 changes: 3 additions & 3 deletions caspar/core/Response.class.php
Expand Up @@ -444,9 +444,9 @@ public function getFooterDecoration()
*/
public function setCookie($key, $value, $expiration = 864000, $base_path = null, $domain = null)
{
$base_path = ($base_path !== null) ? $base_path : Caspar::getBasePath();
$domain = ($domain !== null) ? $domain : Caspar::getBaseURL();
setcookie($key, $value, NOW + $expiration, Caspar::getBasePath());
$base_path = ($base_path !== null) ? $base_path : Caspar::getDefaultCookiePath();
$domain = ($domain !== null) ? $domain : Caspar::getDefaultCookieDomain();
setcookie($key, $value, NOW + $expiration, $base_path, $domain);
return true;
}

Expand Down

0 comments on commit 2e03b9a

Please sign in to comment.