Theoretically, if a PHP Session ID is stored in a Cookie that has a lifetime of 365 days, will the Session ID will resume the right session on day 365 or will the related Session be timed out due to the Session lifetime settings?
The cookie just stores the session id that will identify the session.
If there is a session file corresponding to that id, the session will be resumed – otherwise, a new empty session with that id will be created.
The session.gc_maxlifetime
option is rather misnamed – in fact it is a minimal lifetime. If this timespan has passed after the session file was last accessed, the session garbage collector is allowed to wipe that file from disk – but it is not guaranteed that this will happen immediately, because the garbage collector is called randomly (with what probability on every request can also be configured).
And how long can/should I store and use a Session ID?
For as long as you need it …?
That depends on what you are trying to do, how you have sessions configured, etc.