• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The session "userdata" is always set to "Errors 404" ...

#1
[eluser]pesho_h_k[/eluser]
Hi, guys.

I have this problem - whenever I set some session variables via

$this->session->set_userdata( 'var_name', 'var_value' );

but on another page, where I have to use this session variable - it's always set to "errors 404" ... I mean - the string "errors 404".

I've never met something like this ... it's very embarrassing.
I tried the native session, but the problem still persists. Also, when I dump the $_SESSION array right after the session_start - it already contains this. (But when I dump it right after I set it - it's the correct value.)

And one more thing - I made a simple php script, just with one if-else, that sets the session var and later uses it - and it's OK there - with the $_SESSION array only.
(Could the problem be that session save path is not set? ... locally everything is OK, and locally the save path is set.)

PS: I tried setting more than one variable, only the one I want is wrong on another pages. It's value is coming from the url, with some modifications ... but I don't think that this is the problem, cause when I dump it right after the setting - it's OK there.

#2
[eluser]WanWizard[/eluser]
CodeIgniter doesn't use $_SESSION, so it shouldn't be relevant what is in there.

You retrieve userdata by using $this->session->userdata('var_name');

#3
[eluser]pesho_h_k[/eluser]
Yes, I know that ... and when I need the session variable I'm getting it with $this->session->userdata( 'var_name' ); ...

I mentioned the $_SESSION array cause the native session uses it, and restores it from there. In the previous variant of the session library a cookie was used, and the situation was exactly the same.

#4
[eluser]WanWizard[/eluser]
There's no CI code that contains the string "error 404". Have you searched your code? It must be assigned somewhere...

Where does the value come from you're trying to set? You don't have something missing on your page that causes a second request of index.php (due to a rewrite) that triggers a 404? Enable logging and check your logs.

#5
[eluser]pesho_h_k[/eluser]
Hello,

I did what you did ... and on every page I request (nevermind whether it's the page where the session var should be set, or a page, where the session var should just be used) - I get this log ( $config['log_threshold'] = 4; ) :


DEBUG - 2010-11-28 03:46:42 --> Config Class Initialized
DEBUG - 2010-11-28 03:46:42 --> Hooks Class Initialized
DEBUG - 2010-11-28 03:46:42 --> URI Class Initialized
DEBUG - 2010-11-28 03:46:42 --> Router Class Initialized
DEBUG - 2010-11-28 03:46:42 --> Output Class Initialized
DEBUG - 2010-11-28 03:46:42 --> Input Class Initialized
DEBUG - 2010-11-28 03:46:42 --> Global POST and COOKIE data sanitized
DEBUG - 2010-11-28 03:46:42 --> Language Class Initialized
DEBUG - 2010-11-28 03:46:42 --> Loader Class Initialized
DEBUG - 2010-11-28 03:46:42 --> Helper loaded: url_helper
DEBUG - 2010-11-28 03:46:42 --> Native_session Class Initialized
DEBUG - 2010-11-28 03:46:42 --> Controller Class Initialized
DEBUG - 2010-11-28 03:46:42 --> Helper loaded: form_helper
DEBUG - 2010-11-28 03:46:42 --> Validation Class Initialized
DEBUG - 2010-11-28 03:46:42 --> File loaded: [fullpath]/views/head.php
DEBUG - 2010-11-28 03:46:42 --> File loaded: [fullpath]/views/plumber-nyc.php
DEBUG - 2010-11-28 03:46:42 --> File loaded: [fullpath]/views/foot.php
DEBUG - 2010-11-28 03:46:42 --> Final output sent to browser
DEBUG - 2010-11-28 03:46:42 --> Total execution time: 0.0367

#6
[eluser]WanWizard[/eluser]
I can't help you with native sessions, I've never used it.

But in general, variable values don't fall out of the sky, so you'll have to debug your application to see where this value is assigned. It must be somewhere...

#7
[eluser]pesho_h_k[/eluser]
Hello,

I solved the problem Smile ...

The first step was that I put a die() in the output class, just before sending the html to the browser, and the cookie was all right, and when I put die() just after that - it's wrong.
And after that I inspected html in firebug, and saw that one image from the css is missing.

I fixed the css rule, and then everything went fine Smile

Now it works with both session libraries. Smile


Thanks all of you Wink ... and hope this helps to anyone who has the same problem Wink

#8
[eluser]WanWizard[/eluser]
I've often repeated this here, I think those simple rewrite rules must people use, that test for existence of a file or directory, are very dangerous. A missing file, or a simple typo, will cause a rewrite to index.php.

It's better to store all your assets in a separate /assets directory, and exclude every request to that directory from rewriting.

#9
[eluser]vitoco[/eluser]
[quote author="WanWizard" date="1290982301"]...A missing file, or a simple typo, will cause a rewrite to index.php.
[/quote]
A missing file or a simple typo it's gonna be an error always, and i think that either a 404 error or a rewrite to CI are not acceptable.
[quote author="WanWizard" date="1290982301"]
It's better to store all your assets in a separate /assets directory, and exclude every request to that directory from rewriting.
[/quote]
This one i agreed, as it gets easier to manage.

#10
[eluser]WanWizard[/eluser]
[quote author="vitoco" date="1290989396"]A missing file or a simple typo it's gonna be an error always, and i think that either a 404 error or a rewrite to CI are not acceptable.[/quote]
True, but it's better to just have a not-found on an asset request, then a second load of index.php.

It can cause all kinds of weirdness, even creating database inconsistency. It also adds extra load to your server. And it's less secure, because it allows direct access to all files and directories that exist in the docroot.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.