1
1
1010101010102014-03-31 10:38:57
PHP
101010101010, 2014-03-31 10:38:57

Xampp - how to make sessions work?

There is such a code

if (!isset($_SESSION)) {
    //session_name("u1");
    session_start();
    $_SESSION ['login'] = '$login';
    $_SESSION ['pass'] = '$pass';
    $_SESSION ['auth'] = true;
    $_SESSION ['id'] = '$p_id';
    $_SESSION ['role'] = 'USER';
    echo 'Session registrate!' ;
} else {
    print_r ( $_SESSION ) ;
    unset ( $_SESSION ) ;
}

which always outputs
session register!

xampp server under windows i.e. there shouldn't be any problems with access to the session. The session id is entered in the cookie, the session is also saved in the tmp file. I can't figure out what's wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
101010101010, 2014-03-31
@101010101010

isset($_SESSION) does not make sense to check before we called the session_start() command;
take out session_start(); behind the if-else block and check if login , pass , auth are set.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question