Interista Posted October 22, 2012 Share Posted October 22, 2012 (edited) 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'; } Edited October 22, 2012 by Interista Quote 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 (edited) 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'; } } Edited October 22, 2012 by Interista Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.