By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,967 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,967 IT Pros & Developers. It's quick & easy.

getting function varible and storing it in php session

P: 32
hi guys i'm a little confuse about getting a variable in function and storing it in session example :

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. function loadContent(paging) 
  4. {
  5.       <?      
  6.         $_SESSION['page']=?????? (this is what confuses me because i   
  7.                 have been trying to get the variable "paging" and is not working)
  8.       ?>
  9. }
  10. </head>
  11. <body>
  12. <span style='cursor: pointer;color:#0033FF' onClick='loadContent(2);'>
  13. </body>
  14. </html>
  15.  
does anyone has a suggestion??
Oct 27 '08 #1
Share this Question
Share on Google+
3 Replies


Markus
Expert 5K+
P: 6,050
You can't do that. Once PHP has finished, you can't communicate with it. You'll either have to reload the page and set 'paging' as a URL param (GET) or use AJAX (not sure if AJAX will work for setting sessions).

Ajax tutorial: http://www.tizag.com/ajaxTutorial/

GET tutorial: http://www.tizag.com/phpT/postget.php

Markus.
Oct 27 '08 #2

P: 32
ic thanks markus. but is it possible if i used cookie? if it is possible how do i use itu? thanks in advance
Oct 27 '08 #3

dlite922
Expert 100+
P: 1,584
ic thanks markus. but is it possible if i used cookie? if it is possible how do i use itu? thanks in advance
http://php.about.com/od/advancedphp/qt/php_cookie.htm
Oct 28 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.