Title: getting error: session_start() [function.session-start]: Cannot send session &#8230;
Last modified: August 19, 2016

---

# getting error: session_start() [function.session-start]: Cannot send session …

 *  [canadianjameson](https://wordpress.org/support/users/canadianjameson/)
 * (@canadianjameson)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/getting-error-session_start-functionsession-start-cannot-send-session/)
 * Hi all,
 * I’m trying to modify a PHP / JS script to detect the users screen size and set
   a variable accordingly but I seem to have hit a snag and nobody on codingforums.
   com can help me with it :/
 * I was hoping that someone here might have some insight
    here’s the thread if 
   it helps: [http://www.codingforums.com/showthread.php?t=144521&page=2](http://www.codingforums.com/showthread.php?t=144521&page=2)
 * and here’s the code:
 *     ```
       <script type="text/javascript">
       function nextpage(currlang){
          var url = 'http://www.gryphondor.com?&w=' + screen.width;
          window.location.href = url;
   
       }
       </script>
       ```
   
 * and here’s the PHP`
    <?php
 * /* I pass directly the GET to the variables but you must check
    * first if are
   safe using some code you want. For example I * would restrict $lang to be only‘
   fr’ and ‘en’ and w to be a positive non-zero integer */
 * $w = $_GET[‘w’];
    // and now select the apropriate dir for your resolution //
   first the default, for unexpected values of $w $wpdir = ‘wallpapers’; if($w =
   = 800){ $wpdir .= ‘800’; }elseif($w == 1024){ $wpdir .= ‘1024’; }elseif($w ==
   1152){ $wpdir .= ‘1152’; }elseif($w == 1280){ $wpdir .= ‘1280’; }elseif($w ==
   1600){ $wpdir .= ‘1600’; } // here $wpdir will be ‘wallpapers800’ for example
 * $wpdir .= ‘/’;
 * // constant are really constant, 🙂 so you must define the dirs
    // where you
   have the wallpapers as constant define(‘VL_WALLPAPER_DIR’, $wpdir); `
 * and here’s the error i get:
    session_start() [function.session-start]: Cannot
   send session cache limiter – headers already sent (output started at /mnt/local/
   home/gryphondor/gryphondor.com/wp-content/themes/vistered-little/wallpaper_functions.
   php:53) in /mnt/local/home/gryphondor/gryphondor.com/wp-content/themes/vistered-
   little/wallpaper_functions.php on line 86
 * Any idea why / how I can fix this?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [canadianjameson](https://wordpress.org/support/users/canadianjameson/)
 * (@canadianjameson)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/getting-error-session_start-functionsession-start-cannot-send-session/#post-817061)
 * let me try to place the PHP in code brackets again:
 *     ```
       <?php
   
       /* I pass directly the GET to the variables but you must check
       * first if are safe using some code you want. For example I
       * would restrict $lang to be only 'fr' and 'en' and w to be a positive non-zero integer
       */
   
       $w = $_GET['w'];
       // and now select the apropriate dir for your resolution
       // first the default, for unexpected values of $w
       $wpdir = 'wallpapers';
       if($w == 800){
       $wpdir .= '800';
       }elseif($w == 1024){
       $wpdir .= '1024';
       }elseif($w == 1152){
       $wpdir .= '1152';
       }elseif($w == 1280){
       $wpdir .= '1280';
       }elseif($w == 1600){
       $wpdir .= '1600';
       }
       // here $wpdir will be 'wallpapers800' for example
   
       $wpdir .= '/';
   
       // constant are really constant, :) so you must define the dirs
       // where you have the wallpapers as constant
       define('VL_WALLPAPER_DIR', $wpdir);
       ```
   
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [17 years, 9 months ago](https://wordpress.org/support/topic/getting-error-session_start-functionsession-start-cannot-send-session/#post-817065)
 * > _session\_start() [function.session-start]: Cannot send session cache limiter–
   > headers already sent (output started at /mnt/local/home/gryphondor/gryphondor.
   > com/wp-content/themes/vistered-little/wallpaper\_functions.php:53) in /mnt/
   > local/home/gryphondor/gryphondor.com/wp-content/themes/vistered-little/wallpaper\
   > _functions.php on line 86_
 * It looks like your file is sending some kind of output before it tries to start
   the session, which you can’t do.
 * Post the entire file over on [http://wordpress.pastebin.ca](http://wordpress.pastebin.ca)
   and post the link back here, so we can take a look at it.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘getting error: session_start() [function.session-start]: Cannot send 
session …’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * Last activity: [17 years, 9 months ago](https://wordpress.org/support/topic/getting-error-session_start-functionsession-start-cannot-send-session/#post-817065)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
