Interista Posted October 22, 2012 Share Posted October 22, 2012 Hello , I got error that said , I got this error only in the first set session , after that the error disappear . So as example i send ( cart.php?add=302 ) in URL , And this is what I got : Undefined index: cart_302 in C:\wamp\www\cart.php on line [i]9[/i] I'm using session for store my cart info , this is my session create code : if (isset($_GET['add'])){ $_SESSION['cart_'.$_GET['add']]+='1'; } Link to comment https://forums.phpfreaks.com/topic/269788-error-in-session-undefined-index/ Share on other sites More sharing options...
Interista Posted October 22, 2012 Author Share Posted October 22, 2012 I think I fixed it like this way : if (isset($_GET['add'])){ if (!isset($_SESSION['cart_'.$_GET['add']])){ $_SESSION['cart_'.$_GET['add']]='1'; }else{ $_SESSION['cart_'.$_GET['add']]+='1'; } } Link to comment https://forums.phpfreaks.com/topic/269788-error-in-session-undefined-index/#findComment-1387077 Share on other sites More sharing options...
Jessica Posted October 23, 2012 Share Posted October 23, 2012 Make $_SESSION['cart'] an array. Link to comment https://forums.phpfreaks.com/topic/269788-error-in-session-undefined-index/#findComment-1387105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.