简体   繁体   English

Joomla:现有会话变量在登录后消失了

[英]Joomla: Existing session variables are gone after login

I have a multi page form in a component. 我在组件中有一个多页表单。 It's for the user not necessary to log in at first. 用户无需先登录。 But if they want to save the result they need to log in at one point. 但是,如果他们想保存结果,则需要一次登录。

I save the model in a session so I can access it on any page: 我将模型保存在会话中,因此可以在任何页面上访问它:

$session =& JFactory::getSession();
$session->set( 'model', serialize($model) );

and read it out with: 并用以下命令读出:

$session =& JFactory::getSession(); 
$model = unserialize($session->get( 'model', 'empty' ));

This works well, but if I login on the page the current session is cleared and only filled with log in information afterwards. 这很好用,但是如果我在页面上登录,当前会话将被清除,之后仅填充登录信息。

I checked different sources but the only thing what I find is that the session is cleared at log out, but not at log in. 我检查了不同的来源,但我发现的唯一发现是会话在注销时清除,但在登录时未清除。

Can anybody tell my where this behavior comes from? 有人可以告诉我这种行为的来源吗? And how I can fix it? 以及我该如何解决?

Why not avoid the issue in the first place and use a cookie? 为什么不首先避免该问题并使用cookie? You can read and write cookies directly on the backend if you want so you don't have to rewrite any logic beyond the saving/ reading of the cookies. 您可以根据需要直接在后端读取和写入cookie,这样就不必重写保存/读取cookie之外的任何逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM