How to pass session to the post ajax request

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
cve
Forum Members
Forum Members
Posts: 44
Joined: Wed Jul 07, 2010 10:54 am

How to pass session to the post ajax request

Post by cve »

Hi, I'm working on new module and I need upload image for category, I want to use jquery uploadify plugin so my code for display upload form inputs looks like this:

Code: Select all

$session = session_id();
$action = html_entity_decode($this->_createAjax('category_image_upload', $id, $returnid));

$this->smarty->assign('script', "
<__script__ type='text/javascript'>
$(function() { 
    $('#m1_uploadify').uploadify({
    'uploader'  : '".$this->GetModuleURLPath()."/js/uploadify/uploadify.swf',
    'script'    : '".$action."',
    'cancelImg' : '".$this->GetModuleURLPath()."/js/uploadify/cancel.png',
    'folder'    : '/uploads/shop',
    'auto'      : true,
    'onComplete'  : function(event, ID, fileObj, response, data) {
      console.log(response)
    },
    'scriptData'  : { 'PHPSESSID': '".session_id()."', '_sx_': '".$_REQUEST['_sx_']."' }
  });

})
</__script>
");
Above code works fine, but when I select file througt uploadify and plugin start upload file - in the response in firebug I have redirect to login action... It seems the cms goes log out, my question is why???

cms version: 1.10.3
kubuntu
php 5.3.6
Post Reply

Return to “Developers Discussion”