sayedsohail Posted June 26, 2007 Share Posted June 26, 2007 Hi everyone, I got a scenario where i had to create or set a phpsession from javascript? how could i do that, any help is highly appreciated. if (document.getElementById('make').value !="") { setphp session make } Link to comment https://forums.phpfreaks.com/topic/57245-solved-how-do-i-set-php-session-from-javascript/ Share on other sites More sharing options...
RichardRotterdam Posted June 26, 2007 Share Posted June 26, 2007 Calling a php action from javascript hmmm sounds like ajax or do you want to redirect the page to a php page? which is even easier. Link to comment https://forums.phpfreaks.com/topic/57245-solved-how-do-i-set-php-session-from-javascript/#findComment-283098 Share on other sites More sharing options...
sayedsohail Posted June 26, 2007 Author Share Posted June 26, 2007 actually i want to store a value in javascript and read it in php file. someone suggested me to use cookie, but i am not sure to set the cookie and read this cookie in php any example would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/57245-solved-how-do-i-set-php-session-from-javascript/#findComment-283213 Share on other sites More sharing options...
RichardRotterdam Posted June 27, 2007 Share Posted June 27, 2007 Lets see your problem here correct me if I am wrong. You have a javascript variable that you wish to use as a php variable is this right? Maybe you can give me more detail concerning your problem and what it is that you are trying to accomplish because it seems you have a interesting problem one of my favs probably. If a process needs to be done over more then one page then I would use cookies (a shopping cart for example). But if all your actions need to be done(or it would be nice to handle within one page) then I would avoid cookies and use ajax instead which improve user usability Link to comment https://forums.phpfreaks.com/topic/57245-solved-how-do-i-set-php-session-from-javascript/#findComment-283943 Share on other sites More sharing options...
sayedsohail Posted June 28, 2007 Author Share Posted June 28, 2007 lets make it simple here is the code <html> <head> <script type="text/javascript"> //decalre timer null var timer=null; function delaytimer(b) { window.clearTimeout(timer); timer=window.setTimeout(getValue(b),5000); } function getValue(a) { var x=document.getElementById("a").value.length; alert(x) } </script> </head> <body> <input type='text' id="myHeader" onkeyup="delaytimer('myHeader')"> <p>Type a letter to alert</p> </body> </html> Link to comment https://forums.phpfreaks.com/topic/57245-solved-how-do-i-set-php-session-from-javascript/#findComment-284788 Share on other sites More sharing options...
RichardRotterdam Posted June 28, 2007 Share Posted June 28, 2007 this topic is marked as solved? is it done like that? I can't see what this has to do with javascript communicating with php Link to comment https://forums.phpfreaks.com/topic/57245-solved-how-do-i-set-php-session-from-javascript/#findComment-284855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.