mbetel
(Michiel)
November 25, 2009, 4:03pm
1
I wtote the attached EUploadify widget, which encapsulates the jquery/swf Uploadify widget.
This works fine, but for one thing. When the flash uploader calls the PHP Callback function
it seems that the Session data is lost.
I can pass the session_id and/or session_name in the scriptData var of the widget. However how do I
reload it once I’ve retrieved this from $_POST?
if(!Yii::app()->getSession()->getIsStarted())
{
Yii::app()->getSession()->open();
$this->log('DN SessionId: ' . Yii::app()->getSession()->sessionID);
}
else
Yii::app()->getSession()->setSessionID($_POST['session']);
Does not work.
mbetel
(Michiel)
November 25, 2009, 9:10pm
2
I wtote the attached EUploadify widget, which encapsulates the jquery/swf Uploadify widget.
This works fine, but for one thing. When the flash uploader calls the PHP Callback function
it seems that the Session data is lost.
I can pass the session_id and/or session_name in the scriptData var of the widget. However how do I
reload it once I’ve retrieved this from $_POST?
if(!Yii::app()->getSession()->getIsStarted())
{
Yii::app()->getSession()->open();
$this->log('DN SessionId: ' . Yii::app()->getSession()->sessionID);
}
else
Yii::app()->getSession()->setSessionID($_POST['session']);
Does not work.
I’m dumb… This works:
if(!Yii::app()->getSession()->getIsStarted())
{
Yii::app()->session->sessionID = $_POST['PHPSESSID'];
Yii::app()->session->open();
}
seb
(Serebrov)
November 26, 2009, 2:19pm
3
Also there is a config file solution (from this forum post (in russian)):
// application components
'components'=>array(
'session'=>array(
'class'=>'CHttpSession',
'useTransparentSessionID' =>($_POST['PHPSESSID']) ? true : false,
'cookieMode' =>($_POST['PHPSESSID']) ? 'none' : 'allow',
),
seb
(Serebrov)
November 26, 2009, 2:36pm
4
Also there is already uploadify wrapper extension here.
mbetel
(Michiel)
November 27, 2009, 5:40am
5
I know, but wanted a cleaner ‘code’ only solution where I could set all options in the widget. Which is why I wrote Euploadify.
DarkNSF
December 29, 2009, 9:26pm
6
this solution worked for me:
// application components
'components'=>array(
'session'=>array(
'class'=>'CHttpSession',
'useTransparentSessionID' =>($_POST['PHPSESSID']) ? true : false,
'cookieMode' =>($_POST['PHPSESSID']) ? 'none' : 'allow',
),
sn0rcha
(Ben)
September 13, 2010, 3:20am
7
DarkNSF:
this solution worked for me:
// application components
'components'=>array(
'session'=>array(
'class'=>'CHttpSession',
'useTransparentSessionID' =>($_POST['PHPSESSID']) ? true : false,
'cookieMode' =>($_POST['PHPSESSID']) ? 'none' : 'allow',
),
I can’t get this to work. I can access the $_POST[‘PHPSESSID’] in the script but using the script below;
if(!Yii::app()->getSession()->getIsStarted())
{
Yii::app()->session->sessionID = $_POST[‘PHPSESSID’];
Yii::app()->session->open();
}
in my controller I can’t seem to access Yii::app()->user->getId() nor can I get passed any accessRules() that pertain to a user role or logged in user for that matter. I’m using the 1.1.4 version of Yii.
Any Ideas?
Cheers,
Sn0rcha
MichaelH
(Derinus)
September 23, 2010, 1:37pm
8
I am using 1.1.4 as well and can’t get it to work either.
Yii::app()->getSession()->getIsStarted() will just return true.
I tried setting autoStart to false in my config/main.php file but with no result
seb
(Serebrov)
September 23, 2010, 4:21pm
9
MichaelH:
I am using 1.1.4 as well and can’t get it to work either.
Yii::app()->getSession()->getIsStarted() will just return true.
I tried setting autoStart to false in my config/main.php file but with no result
You need to set session id before yii start session itself.
I done this by setting session id in the index.php:
// change the following paths if necessary
$yii=dirname(__FILE__).'/../yii/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';
// remove the following line when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
require_once($yii);
if (isset($_POST["PHPSESSID"]) && !empty($_POST["PHPSESSID"])) {
session_id($_POST["PHPSESSID"]);
session_start();
} else if (isset($_GET["PHPSESSID"]) && !empty($_GET["PHPSESSID"])) {
session_id($_GET["PHPSESSID"]);
session_start();
}
Yii::createWebApplication($config)->run();
Y11
(Y!!)
September 23, 2010, 5:02pm
10
Try this in the beginning of the entry-script:
if (isset($_POST['PHPSESSID']))
{
$_COOKIE['PHPSESSID'] = $_POST['PHPSESSID'];
}
The session component will then read the correct session id from the cookie as usual.
MichaelH
(Derinus)
February 4, 2011, 3:15pm
11
Thanks this work perfectly.
I put it at the top of the controller action first but then it’s called too late.
it gave a 302 error redirecting to the loginpage because the accessRules function is called before the controller action.
I put it into the module’s init() function and it works great.
22francis
(Jesusloves Francis)
July 2, 2012, 7:38pm
12
Try this in the beginning of the entry-script:
if (isset($_POST['PHPSESSID']))
{
$_COOKIE['PHPSESSID'] = $_POST['PHPSESSID'];
}
The session component will then read the correct session id from the cookie as usual.
Thank you very much i did search for the solution for one whole day…
Thank to Jesus at last i find this…