Welcome Guest, Not a member yet? Register   Sign In
unable to create session cookie
#1

[eluser]basty_dread[/eluser]
I have downloaded a new copy of Codeigniter 1.7.2
and uploaded it to my testing server
everything is configured then i tried this piece of code

Code:
function Welcome(){
        parent::Controller();    
        $this->load->library('session');
        $this->load->helper('url');
    }
    
    function index(){
        $data['user'] = "testing";
        $this->session->set_userdata($data);
        redirect('welcome/check');
    }
    function check(){
        echo $this->session->userdata('user');
    }
this should output "testing" when i run this code.
but nothing happens.

i am using google chrome browser v.5.0.375.127
#2

[eluser]WanWizard[/eluser]
Are you using database sessions? If not, the updated cookie will not be send to the browser due to the redirect.

Does the session itself work? If you don't redirect, but load the check method manually, is the session variable present? If not, the session cookie is not created, and you have to check your configuration in config/config.php. Make sure cookie_domain and cookie_path are configured correctly, and remove the underscore from the cookie name...
#3

[eluser]basty_dread[/eluser]
no i am not using database session
the session works only on firefox.
the cookie domain is correct..
and the cookie path is set to "/"; cookie name doesnt have underscore.
#4

[eluser]basty_dread[/eluser]
Code:
function index(){
        $data['user'] = "testing";
        $this->session->set_userdata($data);
        echo $this->session->userdata('user');
    }

i tried this..it echoed testing..
but as i look into the session on the browser. nothing is saved.
just to make sure i run this code

Code:
function check(){
     echo $this->session->userdata('user');
}

but it did not print testing..
#5

[eluser]WanWizard[/eluser]
I copied this exact code into the welcome controller of a fresh CI installation, and it works as advertised here (using FF 3.6.7 on Linux).

Can you do a
Code:
var_dump($_COOKIE);
in the constructor of your controller, and check when you call index() and check() what the contents is?
#6

[eluser]basty_dread[/eluser]
yes it works perfectly on FF.but on updated(safari/opera/chorme)
it is not working.

same result for index() and check()
Code:
array(0) { }

did you try it on safari or chrome?
#7

[eluser]WanWizard[/eluser]
I don't have a Mac handy, so no safari.

I've justed tested:
- FF 3.6.7 on Linux
- Chrome 6.0.472 on Linux
- FF 3.0 on Windows XP
- Opera 9.52 on Windows XP
- IE6 on Windows XP

They all work.

What exactly are your session and cookie configuration settings?
#8

[eluser]basty_dread[/eluser]
i wondering why.

before it is working.
this is actually what happened.
i reformat my pc. download and install the safari, opera, and chrome.
then as i tried to access my project.. it is not redirecting anymore to the right page.because of the session is not being created.

i tried it to my other pc. and it works ok.

my default config is the default
i just changed the
Code:
$config['base_url']="http://ricardo_ortiz.freehostia.com/"
$config['sess_cookie_name'] = 'ExiteCMSid';
$config['sess_encrypt_cookie']= TRUE;
$config['cookie_domain'] = "ricardo_ortiz.freehostia.com";
$config['cookie_path'] = "/";

Thanks you for sharing your knowledge!
#9

[eluser]WanWizard[/eluser]
I don't have a problem on that site either, session cookie is created without problems.

Must be a local issue then, not something related to your code. Let us know if you find the reason.
#10

[eluser]Bazze[/eluser]
I'm also having this issue. Been working on my site testing everything in firefox. Now decided to login and start testing in Safari, and the login function doesn't work! Storing my sessions in the database. Anyone know what's wrong?




Theme © iAndrew 2016 - Forum software by © MyBB