Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.