In my hospitality site ,a visitor searches hotels(those give offer for a particular date range).If he gets zero records for his search criteria,then he edits his searc开发者_如何学编程h and again searches.when he edits his search he goes back to the page where his previous entered values must be pre-filled.I store those values in the session .But while it goes back,session lost.
There is a search form search.php
. After clicking the Search now
button in the 'search.php', I go to search_result.php
page and the data brought through the POST value are set in the session in 'search_result.php'.
There is a button called "Edit Ur search"
in the search_result.php
page.When I click on it, it should bring me back to search.php
where the values set in the session must be displayed and the search form must be pre-filled with those session values.
In search_result.php
I call edit_search()
on the click event on "Edit Ur search"
button
function edit_search(){
var url = "hotels.php";
self.location = url;
}
But when I return back to search.php I loss the session value. Is it due self.location
clearing the session?
I need to persist all those session values. Any other method to complete the requirement is appreciated.
The search form is @ search.php page.I saved the search criteria inside database.And when the visitor cliked search button and redirected to search_result.php, I show the search criteria by fetching the data from database.In this way I solved my problem.
This problem can also be solved by managing session_start() in anyother page instead of writing in connect_database.php which is included in both search.php and search_result.php.
But as my client's another requirement was also to save the search criteria for further betterment of the site,hence I followed the 1st option mentioned earlier.
Hence I conclude going back through "self.location" was not the reason behind session dye.Rather it was the session_start() written twice in those 2 concer page was the reason of this problem. Thanks...........
精彩评论