techtheatre Posted April 8, 2007 Share Posted April 8, 2007 Is there a maximum length of a value stored in a session variable? I have written a basic shopping cart in PHP and am adding the selected products and options to a single session variable (probably not the best idea, but i don't know what else to do) and i wonder if it would be possible that this string gets too long and products are "forgotten"? I know there is a cut-off length when posting variables from a form using GET, but i am using POST, then combining the data into one (long) string and storing it in $_SESSION['cartcontent'] = "mylongstringhere|seconditemhere|thirditemhere|fourthitemhere" I have googled for "PHP Max Length Session Variable" and not found any info about this. Thanks. Link to comment https://forums.phpfreaks.com/topic/46078-solved-maximum-length-of-a-session-variable-value/ Share on other sites More sharing options...
trq Posted April 8, 2007 Share Posted April 8, 2007 Not that I am aware of. But then again, everything has a limit. Depends on how much memory your server has. Link to comment https://forums.phpfreaks.com/topic/46078-solved-maximum-length-of-a-session-variable-value/#findComment-223914 Share on other sites More sharing options...
techtheatre Posted April 8, 2007 Author Share Posted April 8, 2007 Thanks. I wanted to check before I put too much more energy into this particular part of the script. If i was going to run into a problem, i thought it better to change the process now rather than further down the road. I will leave this as "unresolved" for a couple days in case someone else knows of a limit, but thanks for your response! Link to comment https://forums.phpfreaks.com/topic/46078-solved-maximum-length-of-a-session-variable-value/#findComment-223921 Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Share Posted April 8, 2007 well instead of using the sessiocn as your cart, id write all the items into a database. like id have an item number, a user id, and a cart id. then a date or something, then the item name this way you can veiw a particular cart simply by calling its id...... maybe store the id in a session or something. that way you can always come back to the cart if theres an error or something, or dispute etc. good luck, if you want me to expand, please pm me Link to comment https://forums.phpfreaks.com/topic/46078-solved-maximum-length-of-a-session-variable-value/#findComment-223922 Share on other sites More sharing options...
techtheatre Posted April 8, 2007 Author Share Posted April 8, 2007 Thanks for the tip. My next cart system will store everything in a database, but this one is very basic...so not really necessary at this point. Thanks for everyone's help! Link to comment https://forums.phpfreaks.com/topic/46078-solved-maximum-length-of-a-session-variable-value/#findComment-224553 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.