| | |
How to save session values in JavaScript
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2006
Posts: 6
Reputation:
Solved Threads: 0
There are more ways to do it than just cookies - it basicaly depends if you want to store the session between visits that happend at the same time, or if you want to save sessions for later use.
If the later is what you want, go for cookies:
If you just want to save the session while the user leaves your pages you could use a hidden frame and store the session value inside a hidden input.
If the later is what you want, go for cookies:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); }
If you just want to save the session while the user leaves your pages you could use a hidden frame and store the session value inside a hidden input.
![]() |
Similar Threads
- Save the values of a form (HTML and CSS)
- need help with session values (ASP.NET)
- Save form values - show/hide divs depending on values (JavaScript / DHTML / AJAX)
- Access hidden values by javascript (PHP)
- Hi how to store arraylist values in session state (ASP.NET)
- How to pass the values of javascript in perl (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Request for javascript based editor
- Next Thread: AJAX : Am i right with the concept?
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp animate array automatically beta box bug calendar cart checkbox class codes column cookies createrange() css cursor date debugger decimal design dom download dropdown editor element embed enter error explorer firefox focus frameworks getselection google gwt hint html htmlform ie7 iframe images index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jsp jump listbox maps masterpage math menu microsoft mimic mp4 object onmouseover parent paypal php player position post problem programming progressbar prototype redirect regex runtime safari scale scriptlets search select session shopping size sql text textarea toggle variables w3c website window windowofwords windowsxp wysiwyg \n






