Viewed   323 times

How to solve :

Warning: session_start() [function.session-start]: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in ..... on line 3

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at ......:3) in ..... on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at .....:3) in ..... on line 3



have a look at this session_start() discussion for a work-around:

session_start() generate a warning if PHPSESSID contains illegal characters

Warning: session_start() [function.session-start]: The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in /home/para/dev/mon_site/header.php on line 17

To avoid i wrote this :

        function my_session_start()
            if (ini_get('session.use_cookies') && isset($_COOKIE['PHPSESSID'])) {
                $sessid = $_COOKIE['PHPSESSID'];
            } elseif (!ini_get('session.use_only_cookies') && isset($_GET['PHPSESSID'])) {
                $sessid = $_GET['PHPSESSID'];
            } else {
                return false;

           if (!preg_match('/^[a-z0-9]{32}$/', $sessid)) {
                return false;

           return true;
Monday, December 5, 2022

A session is started with the session_start() function.

Session variables are set with the PHP global variable: $_SESSION.

if you are not using any automatic session handling framework ...if you use your own script then you have to must start session before it can try

// Start the session<br/>

which is set beginning of your script.after that you can use session variables.

Change your html template as such :

<input type="hidden" name="login_email" id="login_email" value="<?php echo $_SESSION['email'];?>" />
<input type="hidden" name="login_user" id="login_user" value="<?php echo $_SESSION['login'];?>" />

Since PHP 5.4 the inline echo short tags are always enabled regardless of the short_open_tag (php.ini) setting.

if it's not enable then please Set

short_open_tag=On in php.ini

after that restart your Apache server then you can use


instead of :

<?php echo $_SESSION['email'];?>

you can try for session.i think it's helpful for you.

and How to enable PHP short tags? for enable php short tags.

Thursday, September 29, 2022

You might be using Mink or Behat. Please, make sure that they are loaded only for their environment and not dev/prod. See:

Monday, October 3, 2022

Max integer value in PHP is 2147483647 for 32 bit platform and Laravel multiplies lifetime value by 60.

So maximum lifetime value is 35791394 for 32-bit platform. It's 68 years, so it's kind of infinity for the session. )

Thursday, December 8, 2022

By adding our .cleanup() method to the String object itself, you can then cleanup any string in Javascript simply by calling a local method, like this:

# Attaching our method to the String Object
String.prototype.cleanup = function() {
   return this.toLowerCase().replace(/[^a-zA-Z0-9]+/g, "-");

# Using our new .cleanup() method
var clean = "Hello World".cleanup(); // "hello-world"

Because there is a plus sign at the end of the regular expression it matches one or more characters. Thus, the output will always have one '-' for each series of one or more non-alphanumeric characters:

# An example to demonstrate the effect of the plus sign in the regular expression above
var foo = "  Hello   World    . . .     ".cleanup(); // "-hello-world-"

Without the plus sign the result would be "--hello-world--------------" for the last example.

Friday, August 19, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :