The comments about poker being one long continuous session are valid, but this doesn't actually translate to saying session length doesn't matter at all.
MinorMisfit makes a great point, that your session length may need to be dictated somewhat by whether or not you can continue playing well, since your profitability depends on your state of mind amongst other game conditions.
But another issue at play here is that the shorter your session length, the lower your hourly will be due to the information-gathering factor. If you don't sit long enough to gather reads on your opponents, then you have to play pretty straightforward, can't get out of line, and ultimately will do a lot of guesswork in
hands regarding how your opponents play.
So if we're talking about live play in particular, yes I would definitely plan to be there a while. My average session length live is about 5 hours, and I definitely never PLAN to play less than 4. If extenuating circumstances pop up that lead me to believe I'm not profitable anymore (let's say I get coolered 3 times and know I'll be playing my C game or worse) then I can leave early. BUT in general I plan to be there a while if I go at all.
This can be a bit different online where you accumulate reads faster, and actually I think you need to fall more on the side of short sessions, because it requires a higher level of focus (especially if you multi table). So I probably would never play more than a 3 hour session online, and I'd always be taking a short stand up/stretch break every 30-60 minutes.
At the end of the day, a lot of it will also come down to you and your preferences though. Just figure out what works for you and then maximize based on that.