• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ General Support (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

Discovered SESSION trick

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
1 post • Page 1 of 1

Postby nyc1 » Thu Jan 10, 2008 3:15 am

Been having trouble with my registration system. So did some debug work.

It works like this:

(page 1) Registration - form page

2) Registration - submit page (define my values and store in a SESSION)

3a) Demo3_client

calls - 3b) Demo3_config (values pulled off my SESSION)

4a) Demo3_server

calls - 4b) Demo3_config (values pulled off my SESSION)


I was discovering that the submit page was accessing old (from prior visit to chat) values in my SESSION. So I decided to use page 1 to clear all old SESSION data related to pfc. So I looked at the entire SESSION array and it turns out there is more in there then I personally set. The pfc software is setting values which I wasn't aware. That might have been reason for some things confusing me, some things being stubborn too. Fortuitously, I was using SESSION nomenclature similar to pfc developer. All pfc SESSION values have a key starting "pfc". Some had "pfc_", but sometimes just "pfc". So on page 1 I unset all the pfc variables in my SESSION like this:

Code: Select all
//--------------------------------------------------------------------------
// Clear SESSION variables stored on prior visits
//--------------------------------------------------------------------------
//echo '<pre>'; // for debug
//echo '<br /><br />before clearing $_SESSION = <br />'; // for debug
//print_r($_SESSION); //for debug
//echo '</pre><br />'; // for debug
// NOTE: I defined all my pfc related SESSION variables similar to the
// pfc developer, we both use "pfc" or "pfc_" at the beggining of key name.
// So will loop thru the SESSION array and for every variable that has
// such a key name, will redefine to empty string "".
foreach ($_SESSION as $key => $value) {
  // check first 3 characters of $key if "pfc".
  if ( strcmp( "pfc", (substr($key,0,3)) )==0 ) {
    unset($_SESSION[$key]);  // unset this SESSION variable
  }
}
//echo '<pre>'; // for debug
//echo '<br /><br />after clearing $_SESSION = <br />'; // for debug
//print_r($_SESSION); //for debug
//echo '</pre><br />'; // for debug

//die('<br />Stop point #1 for debugging');  // for debug

Above is cut and paste from my script. You see how I read the before and after values for debugging, just uncommment those lines.

So this really helped things. Now I can be more dynamic in setting which channels, frozen channels, etc that user can access.

I've also discovered some other coding mistakes I made, particularly setting the array of frozen_channels. So that fixed me too.

Perhaps this will help other people?

After these changes I did the /rehash and at first it didn't seem like things were happy. So I /rehash again, then close window. After starting all over fresh it seems to be more happy. Hope it stays happy.
Last edited by nyc1 on Thu Jan 10, 2008 3:16 am, edited 1 time in total.
nyc1
Member
 
Posts: 20
Joined: Tue Dec 25, 2007 8:02 pm
Top

Post a reply
1 post • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 25 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub