That is nothing but fiction. Assuming that this is in the US, the police would (probably, there are some exceptions) have had to deliver the well-known "Miranda" warnings, that the suspect has the right to silence, the right to consult a lawyer, and the right to have a free lawyer if unable to afford one, and that statements may be used against the subject. If, after those warnings, the suspect chooses to confess, or to make a statement, that confession or statement would be fully admissible, even if the suspect did not have a lawyer present, unless there was some other reason for the statement to be excluded. No such reason is mentioned in the question. It is simply not the case in the US that a confession is excluded just because no lawyer was present, nor is that the law anywhere that I know of.
If the police failed to give the warnings when they were required, then any statements or confessions would be excluded.
The decision in Miranda v. Arizona, 384 U.S. 436 (1966) says:
law enforcement officials took the defendant into custody and interrogated him in a police station for the purpose of obtaining a confession. The police did not effectively advise him of his right to remain silent or of his right to consult with his attorney. Rather, they confronted him with an alleged accomplice who accused him of having perpetrated a murder. When the defendant denied the accusation and said "I didn't shoot Manuel, you did it," they handcuffed him and took him to an interrogation room. There, while handcuffed and standing, he was questioned for four hours until he confessed. During this interrogation, the police denied his request to speak to his attorney, and they prevented his retained attorney, who had come to the police station, from consulting with him. At his trial, the State, over his objection, introduced the confession against him. We held that the statements thus made were constitutionally inadmissible.
the prosecution may not use statements, whether exculpatory or inculpatory, stemming from custodial interrogation of the defendant unless it demonstrates the use of procedural safeguards effective to secure the privilege against self-incrimination. By custodial interrogation, we mean questioning initiated by law enforcement officers after a person has been taken into custody or otherwise deprived of his freedom of action in any significant way. [Footnote 4] As for the procedural safeguards to be employed, unless other fully effective means are devised to inform accused persons of their right of silence and to assure a continuous opportunity to exercise it, the following measures are required. Prior to any questioning, the person must be warned that he has a right to remain silent, that any statement he does make may be used as evidence against him, and that he has a right to the presence of an attorney, either retained or appointed. The defendant may waive effectuation of these rights, provided the waiver is made voluntarily, knowingly and intelligently. If, however, he indicates in any manner and at any stage of the process that he wishes to consult with an attorney before speaking, there can be no questioning. Likewise, if the individual is alone and indicates in any manner that he does not wish to be interrogated, the police may not question him. The mere fact that he may have answered some questions or volunteered some statements on his own does not deprive him of the right to refrain from answering any further inquiries until he has consulted with an attorney and thereafter consents to be questioned.
That tells you exactly what the police are forbidden to do. Nowhere does it say that a lawyer must be present. Indeed it says the opposite:
The defendant may waive effectuation of these rights, provided the waiver is made voluntarily, knowingly and intelligently.
That means that s/he can confess after being warned, and such confession would be admissible, provided that s/he knew and understood those rights.