Support » Plugins » custom sessions broken

  • Hi all,

    I have a custom $_SESSION php file I am including in wp-config.php. It needs <?php session_write_close(); ?> at the end of the pages in order for the session to not break. It works on the main page.

    I thought putting <?php session_write_close(); ?> at the end of footer.php would fix it, but the comments submit action and other pages make the session break.

    Question is: Where all do I need to put <?php session_write_close(); ?> and is including the custom session file in wp-config.php correct?

    I am using the Atahualpa theme and wp 2.9.2


Viewing 7 replies - 1 through 7 (of 7 total)
  • I’d be inclined to start with google in regard to using sessions in WordPress.

    Using sessions with WordPress.

    I say simply because i’ve not gone about doing it myself, and there seems to be a fair bit of info around the web on the topic already.

    Thanks but actually I’ve been searching quite a bit already…

    The most promising answer was one that said to add your variables to those that should not be unset (around line 38 in wp-settings.php). That did not work however.

    I have done plenty of searching on my own to figure this one out with no luck so far. Being able to use my own sessions would be super…

    thanks in advance for any ideas here! 🙂

    A bit more info… is works fine with using built in session handling. But if I want to include a custom session handler (writing to a separate db) then it breaks. The session handler works fine in all other php apps I’ve developed.


    @wp-noob, so you got the solution for this?
    please share here. I need this too..


    oops. I got it.
    just place session_start(); at the top of my plugins.

    thanks 😀

    @takien, I can use just session_start(); but I am trying to include a custom session handler that stores info in a database. Just google “custom session handler” if you’re curious… it’s pretty cool.

    In all other php things I’ve done I’ve had no trouble including a custom session handler…it’s easy… but still no luck here.

    This will be awesome if it’s possible and change a lot of things I do in wp/php for the better! The search goes on 🙂

    I figured it out and it was a dumb error on my part. I left out my session_write_close(); on the theme footer -I was getting mixed result with placing it in other areas and left it out by mistake.

    For anyone using custom session handlers reading this: put the include(‘my_sessions.php’); in the theme’s header and session_write_close(); in the theme’s footer.

    I need more sleep I guess. Thanks for reading, sorry it was user error =/

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘custom sessions broken’ is closed to new replies.