The present invention relates to a method for managing medication of a user, wherein a container (102) for medicaments comprising a storage chamber (102F, 608, 620, 904) and a cap (102A, 602, 618, 704, 914) for closing the storage chamber is used, wherein the container comprises a temperature sensor for measuring temperature inside the container; a humidity sensor for measuring humidity inside the container;an accelerometer sensor (702) arranged in connection with the cap; communication means; and a first connecting part (102D, 606) and a second connecting part (102E) arranged to attach to each other via magnetic forces. The method comprises pre-setting the magnetic force between the first connecting part and the second connecting part to correspond to a given type of container; and recognising the type of container by the acceleration of the second connecting part during the attachment of the second connecting part to the first connecting part.La présente invention concerne un procédé de gestion de la médication d'un utilisateur, dans lequel un contenant (102) pour médicaments comprenant une chambre de stockage (102F, 608, 620, 904) et un capuchon (102A, 602, 618, 704, 914) permettant de fermer la chambre de stockage est utilisé, le contenant comprenant un capteur de température pour mesurer la température à l'intérieur du contenant ; un capteur d'humidité destiné à mesurer l'humidité à l'intérieur du contenant ; un capteur d'accéléromètre (702) disposé en raccordement avec le capuchon ; un moyen de communication ; et une première partie de raccordement (102D, 606) et une seconde partie de raccordement (102E) conçues pour se fixer l'une à l'autre par l'intermédiaire de forces magnétiques. Le procédé consiste à prérégler la force magnétique entre la première partie de raccordement et la seconde partie de raccordement pour correspondre à un type donné de contenant ; et reconnaître le type de contenant par l'accélération de la seconde partie de raccordement pendant la