Codeigniter设置会话变量,但该变量不起作用 [英] codeigniter setting session variable with a variable not working

查看:57
本文介绍了Codeigniter设置会话变量,但该变量不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用在WAMP上本地运行的codeigniter并处理会话。我尝试了默认会话处理程序,数据库会话,本机会话和现在的数据库会话。它们都会导致相同的问题,而我一生无法解决。

Using codeigniter running locally on WAMP and dealing with sessions. I tried the default session handler, db session, native session and now db session. They all result in the same issue and I can't for the life of me figure it out.

问题是我正在尝试使用变量设置会话变量。我已经确认了变量并回显了它,并且在控制器中一切正常。控制器调用一个视图,变量也在那里。该视图调用一个上载程序文件,出于某种原因,这是将变量随机设置为 style.css的地方。如果我静态设置会话,请说 randyval,则它会卡住。只有在尝试使用变量时,它才会中断。

The problem is that I am trying to set a session variable using a variable. I have confirmed the variable and have echoed it out and all is well in the controller. The controller calls on a view and the variable is there as well. The view calls on a uploader file and this is where the variable randomly gets set to "style.css" for some reason. If I set the session statically, say to "randyval", then it sticks. It's only when trying to use a variable that it breaks.

使用数据库会话可以进行以下设置:

Using db session allows me to set using:

$some_val = $some_otherVal;
$_SESSION['sess'] = $some_val;

仅在最后一页中才回显$ _SESSION ['sess']结果为 style.css 。

Only in the final page does echo $_SESSION['sess'] result in "style.css".

但是,如果我这样做:

$_SESSION['sess'] = 'test';

一切正常。

应该除非我是机智的,否则请问...谢谢您的任何投入。

Wouldn't ask unless I was at my wits ends... thanks for any input.

推荐答案

给我愚蠢的表情。 :\事实证明,有一些错误的html导致了问题(?)。是的,它与标头有关,尤其是与调用 style.css文件的位置有关。不知道为什么会破坏会议,但确实如此。因此,很抱歉浪费大家的时间,您现在可以回家。

Color me stupid. :\ Turns out there was some bad html that was causing the problem(?). It had to do with, yeah, you guessed it, the header and more specifically where the "style.css" file was being called. Not sure why that was wrecking the session, but it indeed was. So, sorry for wasting everyones time, you can go home now.

这篇关于Codeigniter设置会话变量,但该变量不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆