Featured post
php - Session issue with unset() and the browser back button -
i'm using session variable set pre-allocated record id postgres (getting record id sequence) using pear's db nextid(). set id session variable because of scoping issues in legacy code i'm working with. after insert happens use unset() remove session variable (this clear used record id). there more information in session remains intact, it's next_id element being removed.
pseudo code:
// next id , set session $_session['next_id'] = $db->nextid(); ... more code here // after insert unset($_session['next_id']);
my question is, clicking button on browser somehow reset session variable $_session['next_id']
? maybe causing null? how cache handle session after element has been removed user has returned previous state?
edit: reason question code in production randomly (by user) trying insert null record id (which next_id session). trying debug process code minimal, reviewed peers , has stumped us???
edit 2: wow guess there issue how i'm using session variable. i'll explain as can why chose method. first code in process on being rewritten php 4, current production version php 4 ton newly added module code in php 5. reason chose session variable because of scoping issue need hard coded on several hundred pages of legacy code or on 1 page , cast value session pages have access to. (well boss pays salary option chose). original problem (my boss) wanted display id end user before insertion of information. hence pear db call nextid(). use postgresql , i'm using record id sequence ensure next id unique , allocated end user (no duplicates postgres handles locking in sequence). end user can navigate multiple pages during process, scoping issue. using session , retrieving next id validation , checks 50 lines of code whole process instead of thousands of lines of code have been written correct way. again not code in first place, making best solution @ least possible cost.
if have another, better, greater, easier, cheaper solution feel free post away. if you're going piss on decision how code, please pay bills , agree following better coding standard,practices,solution.
can't imagine scenario need store nextid() in session used on next page.
as webbiedave pointed out - $_session stored on server, no - hitting button not "reset" session variable.
but, if user hits refresh on second page (the 1 cleared _session variable) script launched again, next_id set null (because set nextid() on previous page)
the same happen if user hits button , previous page loaded browser cache - no request server, no next_id variable in _session.
but still, there wrong if store nextid() in _session.
- Get link
- X
- Other Apps
Comments
Post a Comment