/    Sign up×
Community /Pin to ProfileBookmark

Storing Data To Config File

Hi,

I am having some problems trying to store data into a config file in Codeigniter

[B]The Problem[/B]
The session data grows too big and seems to exceed the 4kb which is the cookie max size. As a result for example flashdata stops working.

[B]Why It Happens[/B]
It seems that config variables are added 4 times into the session inside of following objects:
– CI_Hooks Object (should be turned off)
– CI_Utf8 Object
– MY_Router Object (used for replacing ‘_’ with ‘-‘ in URL)
– CI_URI Object

Interestingly the hooks object is present even if the functionality is turned off in the config file: $config[‘enable_hooks’] = FALSE;

[B[COLOR=”#FF0000″]]Questions[/COLOR][/B]
01 – how do you store config data without it being multiplied in the session?
02 – also, why does the hooks object seem to be enabled when it has been disabled in the config?

[B]Other Details[/B]
– CI_VERSION 2.1.3
– Session library is autoloaded
– Sessions are stored into db
– Session cookie is encrypted
– Config files are loaded in the pages where they are used, mainly inside constructors
– The config data is not huge and would fit very well to 4kb if it wasn’t multiplied

Session data ( print_r($this->session) ) :
[hooks] => CI_Hooks Object ( [enabled] => [hooks] => Array ( ) [in_progress] => ) [config] => CI_Config Object ( [config] => Array…

Thanks in advance for your help, it would be much appreciated…

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@eval_BadCode_Dec 20.2012 — you could serialize the data and write it to a seperate file instead of trying to write it in a configuration file format. It seems like the sensible tool to use in this situation.
Copy linkTweet thisAlerts:
@NogDogDec 20.2012 — I would be a bit surprised if it were a cookie issue, as all the session cookie should include is a session identifier (which is then used to access the session data from wherever you're storing it on the server side. Now, if you're storing the session data in the DB, you may need to change the definition of the column where the data is being stored, so that it can hold more data.

If the config data is already in a file, it does not seem to me that the file data itself should need to be stored in the session data, but instead just the file path/name (or whatever minimal information is needed to know which file to include or read into a variable, or whatever you need to do with it.

Or I'm completely misunderstanding what's going on. ?
×

Success!

Help @oo7ml spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...