Yii Framework Forum: flash callback eats session - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

flash callback eats session Rate Topic: -----

#1 User is offline   mbetel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 26-February 09
  • Location:Netherlands

Posted 25 November 2009 - 11:03 AM

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.
Michiel Betel
0

#2 User is offline   mbetel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 26-February 09
  • Location:Netherlands

Posted 25 November 2009 - 04:10 PM

View Postmbetel, on 25 November 2009 - 11:03 AM, said:

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();
}

Michiel Betel
0

#3 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 26 November 2009 - 09:19 AM

View Postmbetel, on 25 November 2009 - 04:10 PM, said:

I'm dumb.... This works:

if(!Yii::app()->getSession()->getIsStarted()) 
{ 
  Yii::app()->session->sessionID = $_POST['PHPSESSID'];
  Yii::app()->session->open();
}



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',
                ),

0

#4 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 26 November 2009 - 09:36 AM

Also there is already uploadify wrapper extension here.
0

#5 User is offline   mbetel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 26-February 09
  • Location:Netherlands

Posted 27 November 2009 - 12:40 AM

View Postseb, on 26 November 2009 - 09:36 AM, said:

Also there is already uploadify wrapper extension here.


I know, but wanted a cleaner 'code' only solution where I could set all options in the widget. Which is why I wrote Euploadify.
Michiel Betel
0

#6 User is offline   DarkNSF 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 287
  • Joined: 12-November 08
  • Location:Palm Bay, Florida

Posted 29 December 2009 - 04:26 PM

this solution worked for me:


        // application components
        'components'=>array(
                'session'=>array(
                        'class'=>'CHttpSession',
                        'useTransparentSessionID'   =>($_POST['PHPSESSID']) ? true : false,
                        'cookieMode'                =>($_POST['PHPSESSID']) ? 'none' : 'allow',
                ),

0

#7 User is offline   sn0rcha 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 22-June 09

Posted 12 September 2010 - 10:20 PM

View PostDarkNSF, on 29 December 2009 - 04:26 PM, said:

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
0

#8 User is offline   MichaelH 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 09-February 10

Posted 23 September 2010 - 08:37 AM

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
0

#9 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 23 September 2010 - 11:21 AM

View PostMichaelH, on 23 September 2010 - 08:37 AM, said:

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();

0

#10 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 23 September 2010 - 12:02 PM

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.
1

#11 User is offline   MichaelH 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 09-February 10

Posted 04 February 2011 - 10:15 AM

View PostY!!, on 23 September 2010 - 12:02 PM, said:

Try this in the beginning of the entry-script:


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.
0

#12 User is offline   francis ja 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 27-July 11
  • Location:India

Posted 02 July 2012 - 02:38 PM

View PostY!!, on 23 September 2010 - 12:02 PM, said:

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...
skype: jesusloves.francis
Blogs:
http://yiideveloper.wordpress.com/
http://francis-yii-developer.me
Co-founder of Nintriva Wireless
mails:
jesusloves.francis@gmail.com
francis@nintriva.com
http://nintriva.com
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users