Title: Using a session in plugin
Last modified: August 22, 2016

---

# Using a session in plugin

 *  Resolved [Guido](https://wordpress.org/support/users/guido07111975/)
 * (@guido07111975)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-a-session-in-plugin/)
 * Hi,
 * I have a contactform plugin containing a file with plugin funcions and in that
   file I use function ‘include’ to include a second file with the contents of the
   form.
 * That second form starts with a ‘session_start’ because of a certain function 
   I use in frontend. In frontend a session is start when user visits the contactform
   page. The session is destroyed again after form is succesfully send.
 * My question:
    Because lately I’m having some pageload problems in backend I’m
   wondering whether the session can cause this or not? I think so, because when
   I remove it from the second file, pageload is ok again. How to solve this?
 * Guido

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

 *  [Jon (Kenshino)](https://wordpress.org/support/users/kenshino/)
 * (@kenshino)
 * Lord Jon
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-a-session-in-plugin/#post-5898397)
 * Try debugging your code –
 * [http://codex.wordpress.org/Debugging_in_WordPress](http://codex.wordpress.org/Debugging_in_WordPress)
 *  Thread Starter [Guido](https://wordpress.org/support/users/guido07111975/)
 * (@guido07111975)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-a-session-in-plugin/#post-5898461)
 * Yes, of course… forgot about that…
 * Immediately found the issue:
    _Notice: A session had already been started – ignoring
   session\_start() in C:\Program Files\xampp\htdocs_ (etc)
 * My plugin contains 2 files that use session_start > guess that’s causing a conflict…
 * Guido
 *  [Jon (Kenshino)](https://wordpress.org/support/users/kenshino/)
 * (@kenshino)
 * Lord Jon
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-a-session-in-plugin/#post-5898540)
 * This link might help – [http://stackoverflow.com/questions/10648984/php-sessions-that-have-already-been-started](http://stackoverflow.com/questions/10648984/php-sessions-that-have-already-been-started)
 * That or implement a method to check for session status and/or session id before
   you start a session
 *  Thread Starter [Guido](https://wordpress.org/support/users/guido07111975/)
 * (@guido07111975)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/using-a-session-in-plugin/#post-5898553)
 * Thanks, I will use:
 *     ```
       if (!isset ($_SESSION)) session_start();
       ```
   
 * Guido

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

The topic ‘Using a session in plugin’ is closed to new replies.

## Tags

 * [session](https://wordpress.org/support/topic-tag/session/)
 * [session_start](https://wordpress.org/support/topic-tag/session_start/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 4 replies
 * 2 participants
 * Last reply from: [Guido](https://wordpress.org/support/users/guido07111975/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/using-a-session-in-plugin/#post-5898553)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
