Changeset 1623


Ignore:
Timestamp:
Dec 1, 2006, 2:46:32 AM (17 years ago)
Author:
rvelices
Message:
  • sessions are always started (even for visitors)
  • thumbnail order saved in the session instead of cookie
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_session.inc.php

    r1493 r1623  
    8282function cookie_path()
    8383{
    84   if ( isset($_SERVER['REDIRECT_SCRIPT_NAME']) and 
     84  if ( isset($_SERVER['REDIRECT_SCRIPT_NAME']) and
    8585       !empty($_SERVER['REDIRECT_SCRIPT_NAME']) )
    8686  {
     
    222222  return true;
    223223}
     224
     225
     226/**
     227 * persistently stores a variable for the current session
     228 * currently we use standard php sessions but it might change
     229 * @return boolean true on success
     230 * @see pwg_get_session_var, pwg_unset_session_var
     231 */
     232function pwg_set_session_var($var, $value)
     233{
     234  if ( !isset($_SESSION) )
     235    return false;
     236  $_SESSION['pwg_'.$var] = $value;
     237  return true;
     238}
     239
     240/**
     241 * retrieves the value of a persistent variable for the current session
     242 * currently we use standard php sessions but it might change
     243 * @return mixed
     244 * @see pwg_set_session_var, pwg_unset_session_var
     245 */
     246function pwg_get_session_var($var, $default = null)
     247{
     248  if (isset( $_SESSION['pwg_'.$var] ) )
     249  {
     250    return $_SESSION['pwg_'.$var];
     251  }
     252  return $default;
     253}
     254
     255/**
     256 * deletes a persistent variable for the current session
     257 * currently we use standard php sessions but it might change
     258 * @return boolean true on success
     259 * @see pwg_set_session_var, pwg_get_session_var
     260 */
     261function pwg_unset_session_var($var)
     262{
     263  if ( !isset($_SESSION) )
     264    return false;
     265  unset( $_SESSION['pwg_'.$var] );
     266  return true;
     267}
     268
    224269?>
  • trunk/include/section_init.inc.php

    r1606 r1623  
    298298$page['nb_image_page'] = $user['nb_image_page'];
    299299
    300 if (isset($_COOKIE['pwg_image_order'])
    301     and is_numeric($_COOKIE['pwg_image_order'])
    302     and $_COOKIE['pwg_image_order'] > 0)
     300if (pwg_get_session_var('image_order',0) > 0)
    303301{
    304302  $orders = get_category_preferred_image_orders();
     
    306304  $conf['order_by'] = str_replace(
    307305    'ORDER BY ',
    308     'ORDER BY '.$orders[ $_COOKIE['pwg_image_order'] ][1].',',
     306    'ORDER BY '.$orders[ pwg_get_session_var('image_order',0) ][1].',',
    309307    $conf['order_by']
    310308    );
  • trunk/include/user.inc.php

    r1568 r1623  
    4444    redirect(make_index_url());
    4545  }
    46   elseif (empty($_SESSION['pwg_uid']))
    47   { // timeout
    48     setcookie(session_name(),'',0,
    49         ini_get('session.cookie_path'),
    50         ini_get('session.cookie_domain')
    51       );
    52   }
    53   else
     46  elseif (!empty($_SESSION['pwg_uid']))
    5447  {
    5548    $user['id'] = $_SESSION['pwg_uid'];
    5649  }
    5750}
    58 
    5951
    6052// Now check the auto-login
     
    6456}
    6557
     58if (session_id()=="")
     59{
     60  session_start();
     61}
    6662
    6763// using Apache authentication override the above user search
  • trunk/index.php

    r1604 r1623  
    4141if (isset($_GET['image_order']))
    4242{
    43   setcookie(
    44     'pwg_image_order',
    45     $_GET['image_order'] > 0 ? $_GET['image_order'] : '',
    46     0, cookie_path()
    47     );
    48 
     43  if ( (int)$_GET['image_order'] > 0)
     44  {
     45    pwg_set_session_var('image_order', (int)$_GET['image_order']);
     46  }
     47  else
     48  {
     49    pwg_unset_session_var('image_order');
     50  }
    4951  redirect(
    5052    duplicate_index_url(
     
    261263  $template->assign_block_vars( 'preferred_image_order', array() );
    262264
    263   $order_idx = isset($_COOKIE['pwg_image_order'])
    264     ? $_COOKIE['pwg_image_order']
    265     : 0
    266     ;
     265  $order_idx = pwg_get_session_var( 'image_order', 0 );
    267266
    268267  $orders = get_category_preferred_image_orders();
Note: See TracChangeset for help on using the changeset viewer.