Strange session problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi there,

I'm having a strange problem with sessions on my site. I've been using them
(via the $_SESSION) variable with no major problems for some while, but one
particular page seems to be refusing to save the session, although I can't
find any major code differences in the way the session is being handled from
any of the other pages that do work.

The page in question is part of the process for deleting images from the
database, and is meant to show the use what images they're about to delete
and have them verify that they really want to do this.

What the page does is:

- pulls an array of integers from $_POST into a variable called $image_id,
representing the image_id numbers of the image or images the user chose to
delete in a form on the previous page.

- uses that array to query the database for the image titles and paths, and
then displays the images and their titles, and asks if the user is sure they
want to delete these images

- displays a "Yes, I'm sure!" button which the user can click to verify,
which goes to another page which does the deletion and then tells the user
that it's done. The image_id array is written into $_SESSION and passed to
the next page that way rather than via $_POST with the form, because it's an
array and that seemed like the easiest way to pass it.

But what happens is that, while saving the image_id info into $_SESSION is
successful (I can print out $_SESSION at the end of the problem page and it
contains the correct info), when I submit the form and go to the next page,
the session's gone. Trying to print $_SESSION there produces a blank array.

Things I've tried in the course of troubleshooting:

- Replacing the entire following page with one whose sole function is to
print $_SESSION and does absolutely nothing else. Result: it's still blank.

- Using serialize() on $image_id and passing it via a hidden form field,
then unserializing it on the following page. Result: still a blank array,
even though it had the data before serializing it.

- Going directly to the next page by typing the URL into the browser's
location bar, rather than by submitting the form, in case the process of
submitting the form was causing problems. Result: still loses the session.

- Checking to make sure the PHPSESSID cookie was set. Result: it was, and
still was after the session was lost.

- Checked, double-checked, and triple-checked to make sure all pages had
session_start() at the beginning.

I'm completely out of ideas. Does anyone else have any idea what else might
be causing this problem?


Lynna

-- 
Resource Centre Database Coordinator
Gallery 44: www.gallery44.org
Database Project: www.gallery44db.org




[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux