WordPress.org

Ready to get started?Download WordPress

Forums

PHP Session in a page-template? (2 posts)

  1. sepp88
    Member
    Posted 4 years ago #

    I know there are a lot of posts out there in how to enable sessions in wordpress. somehow NOTHING works for me.

    i'm currently working on a custom page template where i want to save a session cookie.

    session_set_cookie_params(0, '/', '.mydomain.com');
    				//session_start();
    				if(!isset($_SESSION['ftp-password']) ) {
    					$_SESSION['ftp-password'] = $_POST['password'];
    				}
    
    				var_dump(ini_get_all('session')); //i can't find the cookie, It's not getting saved

    I've already added the following code to wp-config.php

    // enable sessions
    if (!session_id())
    session_start();

    However i can't quite figure out why my session doesn't get saved.
    Any idea?

    `

  2. digitalmagicianz
    Member
    Posted 3 years ago #

    use session_start at the top of the page

    for example

    <?php
    session_start();
    /*
    Template Name: Page
    */
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.