i want to access the session information in javascript

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
lokesh_kumar_s
Forum Commoner
Posts: 48
Joined: Mon Apr 13, 2009 5:39 am
Contact:

i want to access the session information in javascript

Post by lokesh_kumar_s »

hi i want to access the session information in javascript is it possible, if so then please specify how.
i will provide you the example code. i am setting the session variable in php and i want to access that session variable in javascript.

Code: Select all

 
<?php
$_SESSION['admin']="lokesh";
?>
 
now how can i access $_SESSION['admin'] in php please help
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: i want to access the session information in javascript

Post by VladSun »

Like this:

Code: Select all

<script>
var admin = '<?php echo $_SESSION['admin']; ?>';
</script>
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply