Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

why PHP $_session is not working in wordpress my php code is

session_start();
session_register('lang_opt');  
$_SESSION['lang_opt'] = $_POST['lang_opt'];
$mylang = $_SESSION['lang_opt']; 
echo $mylang;
share|improve this question
    
where are you calling this code? –  Bainternet Apr 7 '12 at 11:45
add comment

1 Answer

Yes, you must use a small change for use session in WordPress.

if ( ! session_id() ) session_start();

Better you use a custom function

function my_start_session() {

@session_cache_limiter('private, must-revalidate'); //private_no_expire
@session_cache_expire(0);
@session_start();
}

*Please edit, I write from a mobile

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.