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['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

1 Answer 1

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

*Please edit, I write from a mobile

share|improve this answer

Your Answer


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.