Using AJAX to secure sessions and save messages
Consider adding User Agent check

Adding a User Agent check will add another layer of security. This will slow down Session Hijacking a bit.

AJAX alone is not a security issue

AJAX is no more vulnerable then regular access when it comes to sessions. 

SES_LENGHT is not defined

The constant SES_LENGHT is not defined anywhere. Is your code snippet complete?