What forms the basis of solidarity varies between societies. In simple societies it may be mainly based around kinship and shared values. In more complex societies there are various theories as to what contributes to a sense of social solidarity.
According to Émile Durkheim, the types of social solidarity correlate with types of society. Durkheim introduced the terms "mechanical" and "organic solidarity" as part of his theory of the development of societies in The Division of Labour in Society (1893). In a society exhibiting mechanical solidarity, its cohesion and integration comes from the homogeneity of individuals—people feel connected through similar work, educational and religious training, and lifestyle. Mechanical solidarity normally operates in "traditional" and small scale societies. In simpler societies (e.g., tribal), solidarity is usually based on kinship ties of familial networks. Organic solidarity comes from the interdependence that arises from specialization of work and the complementarities between people—a development which occurs in "modern" and "industrial" societies.
Definition: it is social cohesion based upon the dependence individuals have on each other in more advanced societies.
Although individuals perform different tasks and often have different values and interest, the order and very solidarity of society depends on their reliance on each other to perform their specified tasks. Organic here is referring to the interdependence of the component parts. Thus social solidarity is maintained in more complex societies through the interdependence of its component parts (e.g., farmers produce the food to feed the factory workers who produce the tractors that allow the farmer to produce the food).
A connection between the biological and the social was of principal importance for the idea of solidarity as expressed by the anarchist ideologist Prince Peter Kropotkin (1842–1921). In his most famous book "Mutual Aid: A Factor of Evolution" (1902), written partly in response to Huxleyan Social Darwinism, Kropotkin studied the use of cooperation as a survival mechanism in human societies at their various stages, as well as with animals. According to him, mutual aid, or cooperation, within a species has been an important factor in the evolution of social institutions. Solidarity is essential for mutual aid; supportive activity towards other people does not result from the expectation of reward, but rather from instinctive feelings of solidarity. In his Introduction to the book, Kropotkin wrote: “The number and importance of mutual-aid institutions which were developed by the creative genius of the savage and half-savage masses, during the earliest clan-period of mankind and still more during the next village-community period, and the immense influence which these early institutions have exercised upon the subsequent development of mankind, down to the present times, induced me to extend my researches to the later, historical periods as well; especially, to study that most interesting period – the free medieval city republics, whose universality and influence upon our modern civilization have not yet been duly appreciated. And finally, I have tried to indicate in brief the immense importance which the mutual-support instincts, inherited by mankind from its extremely long evolution, play even now in our modern society, which is supposed to rest upon the principle "every one for himself, and the State for all," but which it never has succeeded, nor will succeed in realizing”. Kropotkin advocated an alternative economic and social system, which would be coordinated through a horizontal network of voluntary associations with goods distributed in compliance with the physical needs of the individual, rather than according to labor.
Use in philosophy
Solidarity is an emerging concept in contemporary philosophy – it is subject to ongoing studies in various subfields of ethics and political philosophy.
One notable approach in bioethics is to identify solidarity primarily as a three-tiered practice enacted at the interpersonal, communal, and contractual and legal levels. This approach is driven by the quest to differentiate between the diverse applications of the concept and to clarify its meaning, both historically and in terms of its potential as a fruitful concept for contemporary moral, social and political issues.
"Thus, a group's solidarity is a function of two independent factors: first, the extensiveness of its corporate obligations, and, second, the degree to which individual members actually comply with these obligations. Together, these provide the defining elements of solidarity. The greater the average proportion of each member's private resources contributed to collective ends, the greater the solidarity of the group." - Michael Hechter 
International solidarity is "not an act of charity but an act of unity between allies fighting on different terrains toward the same objectives." - Samora Machel
"Unlike solidarity, which is horizontal and takes place between equals, charity is top-down, humiliating those who receive it and never challenging the implicit power relations." - Eduardo Galeano
"The most important word in the language of the working class is solidarity." - Harry Bridges
"Solidarity is not a matter of altruism. Solidarity comes from the inability to tolerate the affront to our own integrity of passive or active collaboration in the oppression of others, and from the deep recognition of our most expansive self-interest. From the recognition that, like it or not, our liberation is bound up with that of every other being on the planet, and that politically, spiritually, in our heart of hearts we know anything else is unaffordable." - Aurora Levins Morales
"Solidarity does not assume that our struggles are the same struggles, or that our pain is the same pain, or that our hope is for the same future. Solidarity involves commitment, and work, as well as the recognition that even if we do not have the same feelings, or the same lives, or the same bodies, we do live on common ground." - Sara Ahmed
"No man is an island, entire of itself; every man is a piece of the continent, a part of the main. If a clod be washed away by the sea, Europe is the less, as well as if a promontory were, as well as if a manor of thy friend's or of thine own were: any man's death diminishes me, because I am involved in mankind, and therefore never send to know for whom the bells tolls; it tolls for thee. Neither can we call this a begging of misery, or a borrowing of misery, as though we were not miserable enough of ourselves, but must fetch in more from the next house, in taking upon us the misery of our neighbours. Truly it were an excusable covetousness if we did, for affliction is a treasure, and scarce any man hath enough of it. No man hath affliction enough that is not matured and ripened by and made fit for God by that affliction. If a man carry treasure in bullion, or in a wedge of gold, and have none coined into current money, his treasure will not defray him as he travels. Tribulation is treasure in the nature of it, but it is not current money in the use of it, except we get nearer and nearer our home, heaven, by it. Another man may be sick too, and sick to death, and this affliction may lie in his bowels, as gold in a mine, and be of no use to him; but this bell, that tells me of his affliction, digs out and applies that gold to me: if by this consideration of another's danger I take mine own into contemplation, and so secure myself, by making my recourse to my God, who is our only security." - John Donne, Meditation XVII