You've already received some good advice about how to glue it back together. I definitely advocate for adding screws to the glue.
I'm going to guess that there's a long lag screw that passes through the head/footboard, and anchors into the bed rail?
If so, that's a pretty bad design, going into the edge of plywood like that. I'd suggest a couple of alternatives, after repairing the split:
A) use brackets
like these instead.
B) use a forstner bit to drill a couple of pockets, and then use bolts and square nuts to hold the rail to the post. See the attached screenshot for reference.
C) similar to B), but you'll use your existing screws. Fill the pockets with dowels, then run a drill bit down the existing screw holes to make a pilot hole through the chunk of dowel.
I've used all three of these techniques, and all seem to hold up really well.