Re: [PHP] Can I retrieve a stored php session variable from within a javascript function?

2005-08-08 Thread Mauricio Pellegrini
Thanks for your advice.
 I've heard of this technique before but wanted to know if there was
another way to do it from Javascript.

Regards 
Mauricio


On Sat, 2005-08-06 at 11:05, Burhan Khalid wrote:
 Mauricio Pellegrini wrote:
  Hi , 
  I wonder if it's possible to retrieve the value from a php session
  variable from within a javascript function.
  
  Does anyone have any ideas about this?
 
 No. You cannot retrieve it, restore it, read it, send it, anything else.
 
 You can write it from PHP :
 
 echo 'script type=text/javascriptvar sess = 
 '.$_SESSION['somevar'].'/script';
 
 But that's it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can I retrieve a stored php session variable from within a javascript function?

2005-08-08 Thread Mauricio Pellegrini
Thanks Rick, it helped.
also I'll do some reading about AJAX (as soon as I can..)

Regards 
Mauricio

On Sat, 2005-08-06 at 11:58, Rick Emery wrote:
 Quoting Mauricio Pellegrini [EMAIL PROTECTED]:
 
  Hi ,
  I wonder if it's possible to retrieve the value from a php session
  variable from within a javascript function.
 
 I'm no PHP expert, but I'll give it a try (there are plenty of smart 
 people on this list who will correct me if Im wrong :-)
 
  Does anyone have any ideas about this?
 
 Yes, two of the top of my head.
 
 1. You can send the session variable to the client along with the script.
 
 ex.
 function doSomething()
 {
sessVar = ?php print($_SESSION['variable']); ?;
 
// Do some stuff.
 }
 
 Of course, sessVar won't be updated if the session variable changes 
 unless the script is reloaded.
 
 2. My favorite, but probably overkill. Write a php page that outputs 
 the session variables (as XML would be cool). Then use xmlhttprequest 
 to retrieve them from javascript (Google AJAX for more information).
 
 Hope this helps,
 Rick
 -- 
 Rick Emery
 
 When once you have tasted flight, you will forever walk the Earth
 with your eyes turned skyward, for there you have been, and there
 you will always long to return
   -- Leonardo Da Vinci

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can I retrieve a stored php session variable from within a javascript function?

2005-08-06 Thread Burhan Khalid

Mauricio Pellegrini wrote:
Hi , 
I wonder if it's possible to retrieve the value from a php session

variable from within a javascript function.

Does anyone have any ideas about this?


No. You cannot retrieve it, restore it, read it, send it, anything else.

You can write it from PHP :

echo 'script type=text/javascriptvar sess = 
'.$_SESSION['somevar'].'/script';


But that's it.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can I retrieve a stored php session variable from within a javascript function?

2005-08-06 Thread Rick Emery

Quoting Mauricio Pellegrini [EMAIL PROTECTED]:


Hi ,
I wonder if it's possible to retrieve the value from a php session
variable from within a javascript function.


I'm no PHP expert, but I'll give it a try (there are plenty of smart 
people on this list who will correct me if Im wrong :-)



Does anyone have any ideas about this?


Yes, two of the top of my head.

1. You can send the session variable to the client along with the script.

ex.
function doSomething()
{
  sessVar = ?php print($_SESSION['variable']); ?;

  // Do some stuff.
}

Of course, sessVar won't be updated if the session variable changes 
unless the script is reloaded.


2. My favorite, but probably overkill. Write a php page that outputs 
the session variables (as XML would be cool). Then use xmlhttprequest 
to retrieve them from javascript (Google AJAX for more information).


Hope this helps,
Rick
--
Rick Emery

When once you have tasted flight, you will forever walk the Earth
with your eyes turned skyward, for there you have been, and there
you will always long to return
 -- Leonardo Da Vinci

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Can I retrieve a stored php session variable from within a javascript function?

2005-08-05 Thread Mauricio Pellegrini
Hi , 
I wonder if it's possible to retrieve the value from a php session
variable from within a javascript function.

Does anyone have any ideas about this?

Thank you 
Mauricio

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php