Jump to content

Regarding PHP sessions


new_to_php

Recommended Posts

Hi ,

I am implementing  seach functionality in a website.

Taking the keyword , search all the pages and storing results in result_array.

Results are displayed PAGE WISE. (like  PREV  1  2  3  NEXT)

If user clicks on "2" I am displaying  from result_array[10] to result_array[19] like that.

So I took result_array as session variable.

session_start();
session_register("result_array");

 

It is working fine , If I took 2 different browsers and test tha functionality on different browsers.

BUT problem is :

1. I open a browser (TAB1), open that website , give a keyword to search.

    Suppos it showed 30 results in 3 pages ( Prev 1  2  3 Next )

    Than , Open new TAB (TAB2) on same browser , open that website , give different keyword for search.

    suppose it shows 50 results in 5 pages  ( Prev 1  2  3  4  5 Next)

   

    NOW go to TAB1  .. Here problem comes , when I click on any page (suppose "2")

  result is over written by TAB2 results.

  I think it is becaues result_array is taken as session variable , how to solve it ?

 

  How to over come this problem.

 

Thank you.

 

 

 

Link to comment
Share on other sites

Re-work your logic from the beginning. Your script is working as you made it, session variables are tied to the specific host and computer in which it is calling it, so if another file is outputting session variables that were assigned in a different file, as long as its the same host/client it'll be the same values.

 

One of the ways to fix your problem is to include the searched text on the page tabs, so it re-runs the query for every tab you choose. Or, you could have all of the pages/tabs outputted and you simply use javascript to navigate from one to the other (they would all be parsed out and unchanged that way).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.