Jump to content

object in cookie


mikachu

Recommended Posts

Hi,

 

I'm working on a multilingual site where i use a lexicon for words that are used repeatedly throughout it. Now I load it every time a page loads from the backend, but i would like it if i can store it on the clients computer, so it's save bandwidth  and the site gets a bit faster.

 

Here is what i had in mind:

 

if (isset($_COOKIE['lexicon_' . $language_obj['id']]))
{
$lexicon_obj = $_COOKIE['lexicon_' . $language_obj['id']];
}
else
{
$lexicon_con = $st->connectObject('site/lexicon/' . $language_obj['id']);
$lexicon_obj = $lexicon_con->getData();

/*
$lexicon_obj looks now like this and i use it throughout the site:
$lexicon_obj['name']
$lexicon_obj['about']
....
*/

setcookie('lexicon_' . $language_obj['id'],	 $lexicon_obj);
}

 

 

When i do this i get an error that it's not permitted to put an array into a cookie. Does someone know a solution for this problem? Or maybe another idea that i haven't thought about?

 

Thanks in advance,

 

Mika

Link to comment
https://forums.phpfreaks.com/topic/64112-object-in-cookie/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.