2

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.

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;

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

If however I do:

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

Everything works as should.

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

6
  • What's the content of "Some_otherVal"? Are you 100% sure you're not overwriting the variable somewhere else?. And sorry for my ignorance, but what is a "dnb"? Commented Oct 15, 2011 at 3:57
  • some_otherVal would just be a string. If it's being overwritten somewhere else, I can't find it. The only difference I can make is by setting it to a specific value. Regardless of the value, it WILL STICK. Only when set to some random does it change and the result is the same "style.css". Not even sure where that's coming from. No worries on your "ignorance" but pardon my stupidity instead. lol. I meant to say db session not database native session and somehow when I said "Using dnb" I meant to say using db session. Not really sure where I got dnb from. :\ I've since corrected it. Commented Oct 15, 2011 at 20:50
  • So, I was hoping this was a WAMP server issue, but even after pushing it to the "live" server on my host, still gives me the same issue. I guess no one else has experienced this same issue. If only I knew why specifically "style.css"... Commented Oct 19, 2011 at 18:05
  • I have a controller in my app, which once the user is verified, calls the db and pulls info on that user and creates a session that stores the username. This controller loads a view and using the db info displays user details. At any point up until now I can call on the session and all information is displayed accurately. This view has a form which loads another php file which I tried a number of ways to get working properly, the only one that worked was to make it a controller as well. It seems that doing this is causing the problem because from here on the session breaks. Thoughs? Commented Oct 19, 2011 at 21:35
  • @John Gomez could you please post the relevant part of that code you're describing? It's not easy imagining what's in there.. Commented Oct 19, 2011 at 21:37

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

This is my problem too! Thanks for pointing out this. I will look at my code now. Would you mind accept your answer as the accepted answer? Thanks! My problem is, the session variable change to images. Sadly, I don't have any folder named 'images'. Any suggestion?
0

You should work with CI sessions using Session Class

4 Comments

I started out using that, but it gave me the described problem. I looked around and saw people having issues with the built in session class and tried using the recommendations all resulting in the same issue. It seems to be something that is being created in my own install as I have not seen this issue anywhere and it seems quite odd. I am currently scouring code to try to find the issue but can't.
what problem did you get? explain better please
I am calling user data from the database. I am then trying to set that data to a session variable. Whenever I do that though, the variable does not stay. It changes to "style.css". No where am I setting anything like that so I don't know where that's coming from. If however I set my session variable to a static string or integer say "random" or 10, it does not change. So, I know the session value itself is not being overwritten.
Show your code, DON'T create another question, but edit this one instead (it will bump it up)
-1

For any of you who stumbled upon this page, see here for the solution : I solved it this way : Losing a session variable between one page with codeigniter session library

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.