TSession se mantem em nova aba/guia Bom dia! Prezados, tenho uma Datagrid(SystemRegistrationsList) que chama uma nova tela(SystemSubscriptionView), nesta é armazenada o $param[‘key’] em uma TSession na função onView para ser utilizado em outras funções. Porém quando o usuário abre uma nova aba/guia do navegador o valor da TSession se mantem o da última aba/guia aberta. SystemRegistrationsList ...
HL
TSession se mantem em nova aba/guia  
Bom dia!
Prezados, tenho uma Datagrid(SystemRegistrationsList) que chama uma nova tela(SystemSubscriptionView), nesta é armazenada o $param[‘key’] em uma TSession na função onView para ser utilizado em outras funções.

Porém quando o usuário abre uma nova aba/guia do navegador o valor da TSession se mantem o da última aba/guia aberta.

SystemRegistrationsList
<?php/** * SystemRegistrationsList * * @version    1.0 * @package    control * @subpackage ps * @author     Hellton Lacerda * @copyright  Serviço Social da Indústria * @license    http://www.adianti.com.br/framework-license */class SystemRegistrationsList extends TPage{       private $datagrid; // listing    private $pageNavigation;    private $loaded;           /**     * Class constructor     * Creates the page, the form and the listing     */    public function __construct()    {        parent::__construct();                $this->form = new BootstrapFormBuilder('form_search_Registrations');        $this->form->setFormTitle( 'Buscar inscrições' );                $this->datagrid = new BootstrapDatagridWrapper(new TDataGrid);        $this->datagrid->datatable = 'true';        $this->datagrid->width = '100%';        $this->datagrid->setHeight(320);                $notice          = new TDataGridColumn('notice', 'Edital', 'center', NULL);        $dtinscricao     = new TDataGridColumn('dtinscricao', 'Data inscrição', 'center', NULL);        $dtinscricao->setTransformer(array($this, 'formatDate_01'));        $unit       = new TDataGridColumn('unit', 'Unidade', 'center', NULL);        $situacao      = new TDataGridColumn('situacao', 'Situação', 'left', NULL);               $order1= new TAction(array($this, 'onReload'));        $order2= new TAction(array($this, 'onReload'));        $order3= new TAction(array($this, 'onReload'));        $order4= new TAction(array($this, 'onReload'));                $order1->setParameter('order', 'notice');        $order2->setParameter('order', 'dtinscricao');        $order3->setParameter('order', 'unit');        $order4->setParameter('order', 'situacao');                $notice->setAction($order1);        $dtinscricao->setAction($order2);        $unit->setAction($order3);        $situacao->setAction($order4);                $this->datagrid->addColumn($notice);        $this->datagrid->addColumn($dtinscricao);        $this->datagrid->addColumn($unit);        $this->datagrid->addColumn($situacao);                $class = 'SystemSubscriptionView';        $action1 = new TDataGridAction(array($class, 'onView'));        $action1->setLabel(('Visualizar edital'));        $action1->setImage('fa:file-text-o fa-fw green');        $action1->setField('id');        //         $class = 'SystemRegistrationsForm';//         $action2 = new TDataGridAction(array($class, 'onEdit'));//         $action2->setLabel(('Inscrição'));//         $action2->setImage('fa:pencil-square-o blue fa-lg');//         $action2->setField('id');                        $this->datagrid->addAction($action1);//         $this->datagrid->addAction($action2);                 // create the datagrid model        $this->datagrid->createModel();                // creates the page navigation        $this->pageNavigation = new TPageNavigation;        $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));        $this->pageNavigation->setWidth($this->datagrid->getWidth());                $panel = new TPanelGroup;        $panel->add($this->datagrid);        $panel->addFooter($this->pageNavigation);                // creates the page structure using a vbox        $container = new TVBox;        $container->style = 'width: 100%';        $container->add($panel);                // add the vbox inside the page        parent::add($container);       }         public function formatDate_01($data_inicio, $object)    {        $data_inicio = new DateTime($data_inicio);        return $data_inicio->format('d/m/Y');    }    public function formatDate_02($data_termino, $object)    {        $data_termino = new DateTime($data_termino);        return $data_termino->format('d/m/Y');    }          function onReload($param = NULL)    {        try        {                        TTransaction::open('permission');                                                            $repository = new TRepository('ViewSystemSubscription');                        $limit = 10;                        $criteria = new TCriteria;                      $criteria->add(new TFilter('system_user_id','=',TSession::getValue('userid')));                        if (empty($param['order']))            {                $param['order'] = 'dtinscricao';                $param['direction'] = 'asc';            }                        $criteria->setProperties($param);             $criteria->setProperty('limit', $limit);                        if (TSession::getValue('SystemRegistrationsList_filter_id')) {                $criteria->add(TSession::getValue('SystemRegistrationsList_filter_id'));             }                                    $objects = $repository->load($criteria, FALSE);                        $this->datagrid->clear();            if ($objects)            {                               foreach ($objects as $object)                {                                        $this->datagrid->addItem($object);                                    }            }                                   $criteria->resetProperties();            $count= $repository->count($criteria);                        $this->pageNavigation->setCount($count);             $this->pageNavigation->setProperties($param);             $this->pageNavigation->setLimit($limit);                                           TTransaction::close();                                    $this->loaded = true;                                 }        catch (Exception $e)         {                       new TMessage('error', '<b>Error</b> ' . $e->getMessage());                                   TTransaction::rollback();        }    }    function show()    {                if (!$this->loaded AND (!isset($_GET['method']) OR $_GET['method'] !== 'onReload') )        {            $this->onReload( func_get_arg(0) );        }        parent::show();    }        function onGenerate($param)    {        $key=$param['key'];        new TMessage('info', 'The name is :'. $key);                $arquivo = './edital/'.$key.'/'.$key.'.pdf';                                       if (!file_exists($arquivo) OR is_writable($arquivo))                    {                     parent::openFile($arquivo);                    }                    else                    {                        throw new Exception(_t('Permission denied') . ': ' . $arquivo);                    }                    TApplication::gotoPage('SystemNoticeList');     }        }?>


SystemSubscriptionView
<?php/** * SystemSubscriptionView * * @package    control * @subpackage ps * @author     Hellton Lacerda * @copyright  Serviço Social da Indústria - Paraíba */class SystemSubscriptionView extends TPage{    protected $form;        function __construct()    {        parent::__construct();                $this->form = new BootstrapFormBuilder('form_System_subscription_view');        $this->form->setFormTitle(('Inscrição') );                $id                        = new TEntry('id');              $user                      = new TEntry('user');        $cpf                       = new TEntry('cpf');        $dtnascimento              = new TEntry('dtnascimento');        $unit                      = new TEntry('unit');        $notice                    = new TEntry('notice');            $dtinscricao               = new TDate('dtinscricao');                $nome_resp                 = new TEntry('nome_resp');        $cpf_resp                  = new TEntry('cpf_resp');        $empresa_resp              = new TEntry('empresa_resp');        $cnpj_resp                 = new TEntry('cnpj_resp');                $escolaridade              = new TCombo('escolaridade');        $estadocivil               = new TCombo('estadocivil');        $renda                     = new TCombo('renda');        $tipo_escola               = new TCombo('tipo_escola');        $escolaanterior            = new TEntry('escolaanterior');                $nt6lp                     = new TEntry('nt6lp');        $nt6mt                     = new TEntry('nt6mt');        $nt6geo                    = new TEntry('nt6geo');        $nt6his                    = new TEntry('nt6his');                $nt7lp                     = new TEntry('nt7lp');        $nt7mt                     = new TEntry('nt7mt');        $nt7geo                    = new TEntry('nt7geo');        $nt7his                    = new TEntry('nt7his');                $nt8lp                     = new TEntry('nt8lp');        $nt8mt                     = new TEntry('nt8mt');        $nt8geo                    = new TEntry('nt8geo');        $nt8his                    = new TEntry('nt8his');                $ntflp                     = new TEntry('ntflp');        $ntfmt                     = new TEntry('ntfmt');        $ntfgeo                    = new TEntry('ntfgeo');        $ntfhis                    = new TEntry('ntfhis');                $ntf                       = new TEntry('ntf');                $situacao                  = new TCombo('situacao');        $motivo_cancelamento       = new TText('motivo_cancelamento');                $situacao->addItems(['A' => 'AGUARDANDO', 'I' => 'INDEFERIDA', 'D' => 'DEFERIDA', 'M' => 'MATRICULADO']);                $id->setEditable(FALSE);                $user->setEditable(FALSE);        $cpf->setEditable(FALSE);        $nome_resp->setEditable(FALSE);        $cpf_resp->setEditable(FALSE);        $empresa_resp->setEditable(FALSE);        $cnpj_resp->setEditable(FALSE);        $unit->setEditable(FALSE);        $notice->setEditable(FALSE);                $nt6lp->setEditable(FALSE);        $nt7lp->setEditable(FALSE);        $nt8lp->setEditable(FALSE);                $nt6mt->setEditable(FALSE);        $nt7mt->setEditable(FALSE);        $nt8mt->setEditable(FALSE);                $nt6geo->setEditable(FALSE);        $nt7geo->setEditable(FALSE);        $nt8geo->setEditable(FALSE);                $nt6his->setEditable(FALSE);        $nt7his->setEditable(FALSE);        $nt8his->setEditable(FALSE);                $ntflp->setEditable(FALSE);        $ntfmt->setEditable(FALSE);        $ntfgeo->setEditable(FALSE);        $ntfhis->setEditable(FALSE);                $ntf->setEditable(FALSE);                  $id->setSize('10%');                        $user->setSize('100%');        $cpf->setSize('100%');        $nome_resp->setSize('100%');        $cpf_resp->setSize('100%');        $empresa_resp->setSize('100%');        $cnpj_resp->setSize('100%');                $unit->setSize('100%');        $notice->setSize('100%');                $nt6lp->setSize('100%');        $nt7lp->setSize('100%');        $nt8lp->setSize('100%');                $nt6mt->setSize('100%');        $nt7mt->setSize('100%');        $nt8mt->setSize('100%');                $nt6geo->setSize('100%');        $nt7geo->setSize('100%');        $nt8geo->setSize('100%');                $nt6his->setSize('100%');        $nt7his->setSize('100%');        $nt8his->setSize('100%');                $ntflp->setSize('100%');        $ntfmt->setSize('100%');        $ntfgeo->setSize('100%');        $ntfhis->setSize('100%');                $ntf->setSize('100%');                $situacao->addValidation(('situação'), new TRequiredValidator);        $motivo_cancelamento->addValidation(('justificativa'), new TRequiredValidator);                $this->form->addFields( [new TLabel(('Número da inscrição'))], [$id]);        $this->form->addFields( [new TLabel(('CPF do candidato'))], [$cpf], [new TLabel(('Candidato'))], [$user]);        $this->form->addFields( [new TLabel(('CPF do responsável'))], [$cpf_resp], [new TLabel(('Nome completo do responsável'))], [$nome_resp] );        $this->form->addFields( [new TLabel(('CNPJ da empresa a qual o responsável é vinculado'))], [$cnpj_resp], [new TLabel(('Nome da empresa a qual o responsável é vinculado'))], [$empresa_resp]);         $this->form->addFields( [new TLabel(('Unidade'))], [$unit], [new TLabel(('Edital'))], [$notice]);                $this->form->addFields( [new TFormSeparator(('Notas'))]);        $this->form->addFields( [new TLabel(('Língua Portuguesa'))], [$nt6lp], [$nt7lp], [$nt8lp]);         $this->form->addFields( [new TLabel(('Matemática'))], [$nt6mt], [$nt7mt], [$nt8mt]);         $this->form->addFields( [new TLabel(('Geografia'))], [$nt6geo], [$nt7geo], [$nt8geo]);        $this->form->addFields( [new TLabel(('História'))], [$nt6his], [$nt7his], [$nt8his]);                $this->form->addFields( [new TLabel(('uuy'))], [new TLabel((''))]);        $this->form->addFields( [new TFormSeparator(('Médias'))]);        $this->form->addFields( [new TLabel(('Lingua Portuguesa'))], [$ntflp], [new TLabel(('Matemática'))], [$ntfmt]);        $this->form->addFields( [new TLabel(('Geografia'))], [$ntfgeo], [new TLabel(('História'))], [$ntfhis]);        $this->form->addFields( [new TLabel(('<br>'))]);        $this->form->addFields( [new TLabel(('Média Final'))], [$ntf]);                TTransaction::open('permission');                $criteria_group = new TCriteria();        $criteria_group->add(new TFilter('system_user_id', '=', TSession::getValue('userid')));                $repository_user_group = new TRepository('SystemUserGroup');        $user_groups = $repository_user_group->load($criteria_group);                foreach($user_groups as $user_group){            $option_user_group[$user_group->system_group_id] = $user_group->system_group_id;        }                TTransaction::close();                    if(in_array('1', $option_user_group )){                        $this->form->addFields( [new TLabel(('Situação'))], [$situacao]);            $this->form->addFields( [new TLabel(('Justificativa'))], [$motivo_cancelamento]);                    $btn = $this->form->addAction(('Salvar'), new TAction(array($this, 'onSave')), 'fa:floppy-o');            $btn->class = 'btn btn-sm btn-primary';        }            $this->datagrid = new BootstrapDatagridWrapper(new TDataGrid);        $this->datagrid->datatable = 'true';        $this->datagrid->width = '100%';        $this->datagrid->setHeight(320);                $id          = new TDataGridColumn('id', 'Nº', 'center', null);        $documento   = new TDataGridColumn('documento', 'Documento', 'center', null);        $id_documento   = new TDataGridColumn('id_documento', 'id_documento', 'center', null);                        $order1= new TAction(array($this, 'onReload'));        $order2= new TAction(array($this, 'onReload'));                 $order1->setParameter('order', 'id');        $order1->setParameter('order', 'documento');                $id->setAction($order1);        $documento->setAction($order1);                $this->datagrid->addColumn($id);        $this->datagrid->addColumn($documento);                $class = 'SystemSubscriptionView';        $action1 = new TDataGridAction(array($class, 'onGenerate'));        $action1->setLabel(_t('View'));        $action1->setImage('fa:edit');        $action1->setField('id_documento');                $this->datagrid->addAction($action1);                $this->datagrid->createModel();                        $panel = new TPanelGroup;        $panel->add($this->datagrid);                $this->datagrid2 = new BootstrapDatagridWrapper(new TDataGrid);        $this->datagrid2->datatable = 'true';        $this->datagrid2->width = '100%';        $this->datagrid2->setHeight(320);                               $dtchange   = new TDataGridColumn('dtchange', 'Data alteração', 'center', null);        $situacao   = new TDataGridColumn('situacao', 'Situação', 'center', null);        $situacao->setTransformer(array($this, 'status'));                        $order1 = new TAction(array($this, 'onReload'));        $order2 = new TAction(array($this, 'onReload'));                 $order1->setParameter('order', 'dtchange');        $order1->setParameter('order', 'situacao');                $dtchange->setAction($order1);        $situacao->setAction($order1);                $this->datagrid2->addColumn($dtchange);        $this->datagrid2->addColumn($situacao);                $this->datagrid2->createModel();                        $panel2 = new TPanelGroup;        $panel2->add($this->datagrid2);                                                $container = new TVBox;        $container->style = 'wihgt: 100px';                $container->add($this->form);        $container->add($panel);        $container->add($panel2);             parent::add($container);    }        public function status($situacao){       if($situacao == 'D'){           $situacao = 'Deferida';       }       if($situacao == 'I'){           $situacao = 'Indeferida';       }       if($situacao == 'A'){           $situacao = 'Aguardando';       }       if($situacao == 'M'){           $situacao = 'Matriculado';       }       return $situacao;    }    function onReload()    {            $this->datagrid->clear();                        $item = new StdClass;        $item->id     = '1';        $item->documento     = 'Certidão de Nascimento';        $item->id_documento     = 'cn_';        $this->datagrid->addItem($item);                $item = new StdClass;        $item->id     = '2';        $item->documento     = 'CPF do Candidato';        $item->id_documento     = 'cpf_cand_';        $this->datagrid->addItem($item);                $item = new StdClass;        $item->id     = '3';        $item->documento     = 'CPF do Responsável';        $item->id_documento     = 'cpf_resp_';        $this->datagrid->addItem($item);                $item = new StdClass;        $item->id     = '4';        $item->documento     = 'RG do Responsável';        $item->id_documento     = 'rg_resp_';        $this->datagrid->addItem($item);                $item = new StdClass;        $item->id     = '5';        $item->documento     = 'Carteira de Trabalho do Responsável';        $item->id_documento     = 'ct_resp_';        $this->datagrid->addItem($item);                $item = new StdClass;        $item->id     = '6';        $item->documento     = 'Comprovante de Residência';        $item->id_documento     = 'cr_';        $this->datagrid->addItem($item);                $item = new StdClass;        $item->id     = '7';        $item->documento     = 'Anexo I';        $item->id_documento     = 'avali_nt_';        $this->datagrid->addItem($item);                TTransaction::open('permission');                $criteria_subscription = new TCriteria();        $criteria_subscription->add(new TFilter('system_subscription_id', '=', TSession::getValue('subscription')));        var_dump(TSession::getValue('subscription'));        $repository_historical_subscription = new TRepository('SystemHistoricalSubscription');                $historical_subscriptions = $repository_historical_subscription->load($criteria_subscription);                $this->datagrid2->clear();                if($historical_subscriptions){            foreach($historical_subscriptions as $historical_subscription){                $this->datagrid2->addItem($historical_subscription);            }        }                TTransaction::close();    }        public function onGenerate($param){                                 $key = $param['key'];                $subscription = TSession::getValue('subscription');                $subscription_array = TSession::getValue('subscription_array');                $arquivo = './doc_alunos/'.$subscription.'/'.$key.''.$subscription.'.pdf';                               if (!file_exists($arquivo) OR is_writable($arquivo))                    {                     parent::openFile($arquivo);                    }                    else                    {                        throw new Exception(_t('Permission denied') . ': ' . $arquivo);                    }                $this->form->setData($subscription_array);                       }                   public function  onView($param)    {        try        {            TSession::setValue('subscription',$param['key']);                                  TTransaction::open('permission');                        $criteria_subscription = new TCriteria;            $criteria_subscription->add(new TFilter('id', '=',$param['key']));                        $repository_subscription = new TRepository('ViewSystemSubscription');            $subscriptions = $repository_subscription->load($criteria_subscription);                        foreach($subscriptions as $subscription){               $subscription;            }                        TSession::setValue('subscription_array', $subscription);                       $this->form->setData($subscription);                        TTransaction::close();                   }        catch (Exception $e)         {                       new TMessage('error', $e->getMessage());        }    }        public function onSave($param)    {        try        {            $object = $this->form->getData('ViewSystemSubscription');            $this->form->validate();            TTransaction::open('permission');            $subscription = new SystemSubscription($object->id);            $subscription->situacao = $object->situacao;            $subscription->motivo_cancelamento = $object->motivo_cancelamento;            $subscription->store();                        $historical_subscription = new SystemHistoricalSubscription();            $historical_subscription->situacao = $object->situacao;            $historical_subscription->justificativa = $object->motivo_cancelamento;            $historical_subscription->dtchange = date('Y-m-d H:i:s');            $historical_subscription->system_subscription_id = $object->id;            $historical_subscription->system_user_id = TSession::getValue('userid');            $historical_subscription->store();                        TTransaction::close();            new TMessage('info', 'Inscrição atualizada com sucesso.');            TApplication::gotoPage('SystemSubscriptionList');                     }        catch (Exception $e)         {            new TMessage('error', $e->getMessage());            TTransaction::rollback();        }    }        function show()    {                if (!$this->loaded AND (!isset($_GET['method']) OR $_GET['method'] !== 'onReload') )        {            $this->onReload( func_get_arg(0) );        }        parent::show();    }                }?>


Segue vídeo (www.screencast.com/t/RpcZtz9j) demostrando o problema.

Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework Quero me inscrever agora!

Comentários (2)


FC

O comportamento está correto a sessão somente se acaba quando fecha o navegador.
MA

Conseguiu resolver o problema?
Caso sim, como foi resolvido?