The syntax of an apex url is f?p=APPLICATION_ID:PAGE_ID:SESSION:REQUEST.
You have defined the link as M.num_app||':'||v('SESSION')||':'||M.REQUEST link
Where M.num_app is probably the application id. If that is the case you're missing the page_id in your link.
The tree link to application 501 should look like this f?p=501:101:476367342376:YOURREQUEST
User your browser webdeveloper tools to see if the url correct is.
Another thing to check is if you are using the same cookie name in all your applications.
This thread Re: Navigating between two apps in the same workspace without singing in again suggest that you don't have to do any coding.
See what happens when you navigate to a page that is not the login page. A non public page.
What I do know from the login process is that it changes the session id.