0


I was trying to make a Json Object of some variables Which I am using as Session variables, But I am not geting the proper Response To make it as Json Object ..
Some Code which I tried (for Reference) Sharing Below..

//Passing the Variable To another PHP File
        session_start();
            $_SESSION['EmailIds']=$strEmailIds;
            $_SESSION['SCHOOL_NAME']=$SCHOOL_NAME;
//sending data to another php page ..
        header('Location: ../SecondPage.php');

In second file SecondPage.php Where i was Using This Session..

session_start();
$SCHOOL_NAME = $_SESSION['SCHOOL_NAME'];//1
$EmailIds= $_SESSION['EmailIds'];//1 <br>

Now trying to make this Session Variable in Json OBject...????

var OBJ = jsonObj.(SCHOOL_NAME+EmailIds);// Confuse with THis Line<br>

Actuaaly Not Getting What is the Good Approach To make this variables as Json Objects..
AS I Made this Json Object I can Use This AS another Purpose Like to send as Ajax Data and etc..

2
  • I have to make an Variable in JavaScript to send this data as ajax.. Commented Feb 16, 2016 at 7:35
  • can some some tell me, How to make my one Variable as EMAIL ID Like a Clickable ... And Send this Email ID to another PHP File... ????? Commented Feb 16, 2016 at 8:00

2 Answers 2

1

You can use json_encode method like this :

$someArray; //can be array of your values or $_SESSION
$jsonObj = json_encode($someArray);
Sign up to request clarification or add additional context in comments.

3 Comments

You mean I have make an Array firstly than.. Convert It into the JavaScript Variable
no you dont have to use javascript variable json_encode is php mehod. Refer this : php.net/manual/en/function.json-encode.php
Thanks Bro... Got It...!!
0

get session data in an array like : $data['SCHOOL_NAME'] = $_SESSION['SCHOOL_NAME']; $data['EmailIds']= $_SESSION['EmailIds'];

then encode it like $json_obj = json_encode($data);

1 Comment

Thanks For compliment .. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.