Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Cookies Leaving A Bitter After Taste
#1

[eluser]TheFuzzy0ne[/eluser]
I'm having a slight problem with cookies. It's nothing too serious, but it is strange nonetheless.

I'm using encrypted cookies on my development server. They've worked fine since I installed CodeIgniter and configured it. I decided to not to bother encrypting my cookies for my development server, as I don't think it's really necessary, but here's the thing -- They don't seem to work correctly without. The standard session data is stored in the cookie, but as soon as I make another request to the server, the cookie remains intact, but none of my data is added.

The data I'm adding is simply an ID, which I'm adding with the key name "id". I've tried clearing my cookies, and I just can't login. Re-enabling encryption again makes everything work again.

I'm going to keep my cookies encrypted for now. It's not a serious problem, it's just very strange that they don't seem to work as expected without encryption. Has anyone else experienced a similar problem?

The only change I've made that could have anything to do with it, is this:

Code:
<?php
/**
* This class extends the core Encrypt class, and allows you
* to use encrypted strings in your URLs.
*/
class MY_Encrypt extends CI_Encrypt
{
    /**
     * Encodes a string.
     *
     * @param string $string The string to encrypt.
     * @param string $key[optional] The key to encrypt with.
     * @param bool $url_safe[optional] Specifies whether or not the
     *                returned string should be url-safe.
     * @return string
     */
    function encode($string, $key="", $url_safe=FALSE)
    {
        $ret = parent::encode($string, $key);
        
        if ($url_safe)
        {
            $ret = strtr(
                    $ret,
                    array(
                        '+' => '.',
                        '=' => '-',
                        '/' => '~'
                    )
                );
        }
        
        return $ret;
    }
    
    /**
     * Decodes the given string.
     *
     * @access public
     * @param string $string The encrypted string to decrypt.
     * @param string $key[optional] The key to use for decryption.
     * @return string
     */
    function decode($string, $key="")
    {
        $string = strtr(
                $string,
                array(
                    '.' => '+',
                    '-' => '=',
                    '~' => '/'
                )
            );
            
        return parent::decode($string, $key);
    }
}

// End of file: MY_Encrypt.php
// Location: ./system/application/helpers/MY_Encrypt.php

But this isn't used when encryption is disabled, which is when I am getting the problems.


Messages In This Thread
CodeIgniter Cookies Leaving A Bitter After Taste - by El Forum - 05-21-2009, 04:34 AM
CodeIgniter Cookies Leaving A Bitter After Taste - by El Forum - 05-21-2009, 07:41 AM
CodeIgniter Cookies Leaving A Bitter After Taste - by El Forum - 05-21-2009, 08:11 AM
CodeIgniter Cookies Leaving A Bitter After Taste - by El Forum - 05-21-2009, 08:18 AM
CodeIgniter Cookies Leaving A Bitter After Taste - by El Forum - 05-21-2009, 08:21 AM
CodeIgniter Cookies Leaving A Bitter After Taste - by El Forum - 05-21-2009, 12:52 PM
CodeIgniter Cookies Leaving A Bitter After Taste - by El Forum - 05-21-2009, 08:44 PM
CodeIgniter Cookies Leaving A Bitter After Taste - by El Forum - 05-22-2009, 03:31 AM
CodeIgniter Cookies Leaving A Bitter After Taste - by El Forum - 07-10-2009, 10:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB