PHPに惚れました

今でも多分惚れてます。

smartyでsessionの値が参照できない

3/31追記

色々グーグル先生に聞きまくって行きついたサイト。

Smarty 2.6.25 はダメ: 粗忽(そこつ)のぶろぐ ― a hasty fellow diary ―
http://bitchesbrew.asablo.jp/blog/2010/01/15/4815658

自作の伝言板アプリが動かなくなった。
原因はsmartyの予約変数、$smarty.sessionが
参照できなくなっていたのだけど、何故なのかを探る
のにえらい時間とられた。。

結局、ネットで検索したところ、2.6.25のバグということで、
本当の最新版2.6.26にしたところ、ようやく動いた。。

ぬぁんだとぅーーーーー!!(若本風

                                                                                                                                                                                                                      • -

3時間ほど試行錯誤して全くいい結果が得られず。

PHP側で$_SESSION['hoge']は参照できるのに、Smartyの.tpl側で{$smarty.session.hoge}が参照できません。

環境
さくらレンタルサーバ

どなたか原因が分かる方、思い当たることがある方、ご教授ください。お願いします。

施してみたこと

    • セッションIDを手動でsesにしてみた(変化なし)
    • コンパイル済みのテンプレートファイルを削除して再生成(変化なし)
    • mod_rewriteを疑い、rewriteが無関係なページでsessionのテスト(ここでも参照出来ず)
    • php.iniを確認。(文字エンコやインクルードパスの設定のみなので思い当たる所なし。)
<?php
require("smarty/Smarty.class.php");
require("MDB2.php");

class MySmarty extends Smarty{
	private $_db;

	public function __construct(){
		$this->Smarty();
		$this->template_dir="〜〜php/smarty/templates/";
		$this->compile_dir="〜〜php/smarty/templates_c/";
		$this->config_dir="〜〜php/smarty/config/";
		$this->config_load("config.conf",basename($_SERVER['SCRIPT_NAME'],".php"));
		$this->caching=2;
		$this->cache_dir="〜〜php/smarty/cache/";
		$this->cache_lifetime=60*15;
		//$this->security=False;

		$dsn=array("phptype"=>"***","username"=>"***","password"=>"***","hostspec"=>"***","database"=>"***");
		$this->_db=MDB2::connect($dsn);
		$this->_db->query("SET NAMES utf8");
	}

	public function __destruct(){
		$this->_db->disconnect();
	}

	public function getDb(){
		return $this->_db;
	}
}
<?php
//login.php
〜〜略〜〜
if($mb->getObject()->isDoCoMo()){  //docomoならばTrue
	ini_set('session.auto_start', 0);
	ini_set("session.use_cookies",0);
	ini_set("session.use_trans_sid",1);
	ini_set("session.name", "ses");
	if(isset( $_GET['ses'])){
		$sessionId = $_GET['ses'];
		session_id($sessionId);
	}
}

〜〜略〜〜

session_start();
$_SESSION['name'] = $data['name'];

if($mb->getObject()->isDoCoMo()){  //端末がdocomoならTrue
	header("Location: /tr/home?guid=ON&".session_name()."=".strip_tags(session_id()));
}else{
	header("Location: /tr/home?guid=ON");
}
?>
<?php
// /tr/home

$smarty = new MySmarty();
$smarty->caching=0;
$smarty->load_filter('output', 'convert_encoding');  //UTF-8からShift-jisに変換するフィルタ

if($mb->getObject()->isDoCoMo()){
	ini_set('session.auto_start', 0);
	ini_set("session.use_cookies",0);
	ini_set("session.use_trans_sid",1);
	ini_set("session.name", "ses");
	if  (  isset( $_GET['ses'] )){
		$sessionId  =  $_GET['ses'] ;
		session_id( $sessionId ) ;
	}
}

session_start();
if($_SESSION['name']===NULL){
	$smarty->assign("err_mes","セッションが切れています。<br />発行されたURLから再ログインしてください。");
	$smarty->display("templates/mobile/common/error.tpl");
	exit();
}

$smarty->display("templates/mobile/home.tpl");

?>
<!--home.tpl-->
{include file="mobile/common/header.tpl"}
{$smarty.session.name}さんのマイページ
<hr>
<ol style="padding:0 5px;">
<li><a href="/tr/gps?guid=ON" accesskey="1">メニュー1</a></li>
<li><a href="/tr/friend?guid=ON" accesskey="2">メニュー2</a></li>
<br />
<li><a href="/tr/logout?guid=ON">ログアウト</a></li>
</ol>
<hr>
{include file="mobile/common/footer.tpl"}