I can share a documents in alfresco, but i need to do the same for folder as well,but I don't know how, anyone could help me out?
Just like an idea, you can use permission on an specific folder and adding user to a group with level access. Another option could be try to develop an action.
Information about permission:
Managing file and folder permissions | Alfresco Documentation
Take a look to the Alfresco Add-ons.
You can implement in the similar way how Document Share is implemented but you need to implement UI for listing Children when a shared Folder URL is called from the browser, which will list all documents and sub-folders under that shared folder.
There's an aspect named QuickShareModel.APSECT_QSHARE which gets applied on a document, when user shares a document. The sharedID property is added to the shared document for retrieval and preview. Check QuickShareServiceImpl class for more details.
Retrieving data ...