![]() |
session header error!!! - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: session header error!!! (/showthread.php?tid=28518) |
session header error!!! - El Forum - 03-13-2010 [eluser]bang_dayat[/eluser] I learn about Thomas myer book,..it pass both of PHP Session and CI Session to develop Shopping cart application,..I create the Model like this: Quote:<?phpthen in the cart controller like this: Quote:function cart($productid=0){but in the first time I run that application,,I found the error message like this: Quote:A PHP Error was encountered Quote:A PHP Error was encountered Quote:A PHP Error was encounteredPlease Someone Help Me to find the Problem,,..Thanx A LOT session header error!!! - El Forum - 03-13-2010 [eluser]JanDoToDo[/eluser] if you are using the native php sessions then you need to call session_start() to start the php session. If youve done that then cart variable doesnt exist and you should do $cart = isset($_SESSION[‘cart’]) ? $_SESSION[‘cart’] : array(); session header error!!! - El Forum - 03-13-2010 [eluser]bang_dayat[/eluser] [quote author="JanDoToDo" date="1268525996"]if you are using the native php sessions then you need to call session_start() to start the php session. If youve done that then cart variable doesnt exist and you should do $cart = isset($_SESSION[‘cart’]) ? $_SESSION[‘cart’] : array();[/quote] yeaa,..that's work,,..I have allready call session_start() in the parent::controller(); but how do you explain bout that code Quote:$cart = isset($_SESSION[‘cart’]) ? $_SESSION[‘cart’] : array();It's Really work!!how the way it can work like that?? Thanx,... session header error!!! - El Forum - 03-13-2010 [eluser]JanDoToDo[/eluser] Its called a ternary operator. Its a shorthand IF statement. it tests the first condition, i.e. isset($_SESSION['cart']) and then if that returns true it assigns $cart a value of $_SESSION['cart'] else it assigns it as an empty array fo you to work with ![]() session header error!!! - El Forum - 03-13-2010 [eluser]bang_dayat[/eluser] [quote author="JanDoToDo" date="1268528416"]Its called a ternary operator. Its a shorthand IF statement. it tests the first condition, i.e. isset($_SESSION['cart']) and then if that returns true it assigns $cart a value of $_SESSION['cart'] else it assigns it as an empty array fo you to work with ![]() yeaa,,I got it,..you and wikipedia really help me bout that "ternary operator"... my last question is,,I call the ci session Quote:$this->session->set_flashdata('conf msg',"anda telah menambah produk ini ke keranjang belanja");then in the view I call that session look like this: Quote:<?phpbut that message not appear in the browser,..perhaps you can help bout that,.. really Thanx,.. session header error!!! - El Forum - 03-13-2010 [eluser]JanDoToDo[/eluser] You're setting "conf msg" but calling "conf_msg" ![]() ![]() session header error!!! - El Forum - 03-13-2010 [eluser]bang_dayat[/eluser] [quote author="JanDoToDo" date="1268532539"]You're setting "conf msg" but calling "conf_msg" ![]() ![]() hahaha,..that's really lost in my eyes,.. :red: anyway thanx a lot brad,..God Bless U :lol: session header error!!! - El Forum - 03-13-2010 [eluser]JanDoToDo[/eluser] NP man ![]() ![]() |