2010-10-27 50 views
1

所以我基本上無法在Kohana 3項目中使用任何類型的會話。這個問題的幾個例子:Kohana 3中的PHP會話3

$session = Session::instance(); 
$session->set('customer_id', $customer->id); 
$this->request->redirect('controller/action'); 
//At the start of the redirected action 
$session = Session::instance(); 
$customer_id = $session->get('customer_id'); 

$ CUSTOMER_ID,在會話中,具有重定向之前正值,它的值爲0。我也試圖與PHP基本會話之後 - 這可能會被禁用在Kohana - 我不知道。沒有想到,因爲我們仍然可以使用$ _GET和$ _POST。

session_start(); 
$_SESSION['customer_id'] = $customer->id; 
//At the start of the redirected action 
session_start(); 
$customer_id = $_SESSION['customer_id']; 

與之前的情況相同,只是現在重定向後的$ customer_id爲空。

不知道現在該怎麼嘗試,我確實在php.ini中啓用了Sessions(我有很多其他應用程序,在其他框架或CMS下,當前已安裝,並且我相信至少有一個應用程序他們使用會話)。目前我正在研究:http://forum.kohanaframework.org/discussion/3018/using-native-session-array/p1,但我懷疑這是問題。

回答

6

不知道當我測試這個時我在想什麼 - 但我解決了這個問題。我不得不猜測這個問題是我自己的愚蠢。

+2

您可以標記爲已解決並提供您的答案。 – 2010-10-29 16:32:09

+0

最後我的代碼是正確的,錯誤與會話完全無關。 – Afrosimon 2010-10-29 19:58:38

+1

你的「修復」是什麼?因爲我認爲我可能也有同樣深刻的腦部放屁。我有同樣的問題。 – DondeEstaMiCulo 2011-04-15 09:11:26