yes it is legal as long as it goes with both parties' consent . but during your stay there, it is better to inform local police about your stay although it not not related your primary question.