gevo12321 Posted December 12, 2008 Share Posted December 12, 2008 I was wondering if it is possible to use sessions with ajax. I use AJAX to open tabs on the page for searching. If a tab is clicked, it will search in one database, if the other is clicked it will search in another and I use AJAX because the whole page doesn't have to reload every time the tab is clicked. I was wondering if I could use sessions to remember which tab was clicked. so when another page loads, it remembers which was clicked. So I was wondering how I would implement this. I just don't see what I would do. Thank you. Link to comment https://forums.phpfreaks.com/topic/136709-solved-sessions-with-ajax/ Share on other sites More sharing options...
Brian W Posted December 12, 2008 Share Posted December 12, 2008 the page that AJAX uses to load needs to set the session to some unique identifier for that tab which you can use on the other pages. Link to comment https://forums.phpfreaks.com/topic/136709-solved-sessions-with-ajax/#findComment-713887 Share on other sites More sharing options...
rhodesa Posted December 12, 2008 Share Posted December 12, 2008 ajax is just a normal client->server page request, so sessions are available just like if they loaded another page from your site. if you want to remember which tab is selected, just pass the tab name in the ajax request, store it in the session, then load it from the session when the new page is loaded. does that make sense? Link to comment https://forums.phpfreaks.com/topic/136709-solved-sessions-with-ajax/#findComment-713888 Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 When you get your data from the database assign a session $_SESSION['tab'] = 'whichevertab' Then look for that session on the next page EDIT: what rhodesa said Link to comment https://forums.phpfreaks.com/topic/136709-solved-sessions-with-ajax/#findComment-713891 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.