cartCookieDuration and purgeInactiveCartsDuration config settings How do I set the cartCookieDuration and purgeInactiveCartsDuration for only 24 hours?
If you go to the Commerce documentation for each (https://craftcommerce.com/docs/configuration#cartcookieduration and https://craftcommerce.com/docs/configuration#purgeinactivecartsduration), they both link to the PHP DateInterval class page that describes the various time formats you can use.

For 24 hours, either P24H or P1D should do it.