Welcome Guest, Not a member yet? Register   Sign In
please i cant understand session
#11

[eluser]Michael Wales[/eluser]
You would just set the input data to the session within your form processor and then use the session text from there on out.
#12

[eluser]mrphp[/eluser]
ok i catch the main problem which let me fail in session

when i load the session library

this error appear
Quote:A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\wamp\www\myforum\index.php:2)

Filename: libraries/Session.php

Line Number: 662

when i stop setcookie the error disappear , i try to search in the forum and the people said remove spaces before <?php and after ?> and actually there are no spaces in my files
#13

[eluser]Michael Wales[/eluser]
Quote:when i stop setcookie the error disappear
huh?

Show some code...
#14

[eluser]mrphp[/eluser]
hahahahahaha

i know that is incorrect but i didnt know the source of the problem . i know that when i stop this code it will not work

but what is the soulotion?
#15

[eluser]Michael Wales[/eluser]
I don't know the solution because I have no idea what the problem is. The most common issue for this is white-space before/after <?php ?>

You can try removing the ?> at the end of your files, this will make PHP automatically trim out whitespace.
#16

[eluser]mrphp[/eluser]
ok now i install a fresh copy of ci
edit the welcom file
Quote:<?php

class Welcome extends Controller {

function Welcome()
{
parent::Controller();
$this->load->library('session');
}

function index()
{
$user=array('user_name'=>'ahmed','logged_in'=>TRUE);
$this->session->set_userdata($user);

echo $this->session->userdata('user_name');
}
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */

and this error appear
Quote:A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\wamp\www\see\system\application\controllers\welcome.php:14)

Filename: libraries/Session.php

Line Number: 662

ok it is afresh copy (CodeIgniter_1.7.0)
#17

[eluser]Tri Dang[/eluser]
I copy your code to my CI welcome controller and I can see "ahmed" in my browser with no problem.

Please, replace this welcome.php with your welcome.php to see if the problem persist. (Rename it as welcome.php)
#18

[eluser]Tri Dang[/eluser]
I copy your code to my CI welcome controller and I can see "ahmed" in my browser with no problem.

Please, replace this welcome.php with your welcome.php to see if the problem persist.
#19

[eluser]mrphp[/eluser]
thank you Tri Dang your file is working correctly
#20

[eluser]Tri Dang[/eluser]
You're welcome Smile




Theme © iAndrew 2016 - Forum software by © MyBB