I think what you're doing architecturally does not make sense. If this cookie is for authenticating a user session, it should be handled through a request made by the browser. If the cookie is just for service calls and you're using the RestServices module, you can get the cookie using the Java actions "getResponseCookies" and then "addRequestCookies" for subsequent calls.
Why do you want to set a cookie, are you absolutely sure this is necessary?
I believe the only way you can set a cookie is by directing the user to a custom request handler. You could use the URL redirector widget (https://appstore.home.mendix.com/link/app/113/Mendix/URL-Redirector) to direct a user to the request handler. In the request handler, you have access to request.addCookie() methods.
So if i am getting session token through rest service , how can i set that session token in cookie?
how can i set that as user session?
This cookie will be used by other mendix app too