Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-23-2006, 03:49 PM
Mickie D Mickie D is offline
 
Join Date: Jun 2002
Posts: 430
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default how does sessions work ?

i was wondering about sessions and wondered if anyone was experianced with using this feature and maybe can help a little ?

Say i had a page that had a form and the form sent infomation to another page (say a small popup - not adverts but info) and i would only want that page to display the info if the page i made sent the request ?

hope that sounds right it was a little difficult to explain and i think sessions can do this ?

for example if someone else sent the request i would want it to display the you do not have permission template ?

thanks for any advice
Reply With Quote
  #2  
Old 01-23-2006, 03:57 PM
sde sde is offline
 
Join Date: May 2002
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you can set session variables like this:
PHP Code:
<?
$_SESSION['canViewTemplate'] = true;
?>
Then in your popup, you could test for it like this:
PHP Code:
<?
if ($_SESSION['canViewTemplate']) {
  // ok
} else {
  // not ok
}
?>
I know the PHP side of things.. not sure about displaying templates. I'm trying to figure this out myself in a post I made today.
Reply With Quote
  #3  
Old 01-23-2006, 05:55 PM
Mickie D Mickie D is offline
 
Join Date: Jun 2002
Posts: 430
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so if i done something like this from the showpost.php page

insert somewhere

PHP Code:
$_SESSION['camefromshowpost'] = true
and in my new page whatever.php

add

PHP Code:
if ($_SESSION['camefromshowpost']) { 
  
$whatever "yes";
} else { 
  
$whatever "no";


thanks very much for the reply
Reply With Quote
  #4  
Old 01-23-2006, 06:02 PM
sde sde is offline
 
Join Date: May 2002
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well once that is set, it is set for the entire session. you aren't really testing where they came from, you are testing if they have visited the page once during this session.

if you truely want to make sure they came from a certain page, use $_SERVER['HTTP_REFERER'].

for example, all you need on the popup page is:
PHP Code:
<?
if ( strstr($_SERVER['HTTP_REREFER'], "mydomain.com/mypage.php") ) {
  $whatever = "yes";
} else { 
  $whatever = "no";
}
?>
I use strstr to compare because the referer might be different if it's a page that has query variables in the url. i.e. http://mydomain.com/mypage.php?f=1&b=2
Reply With Quote
  #5  
Old 01-23-2006, 06:51 PM
Mickie D Mickie D is offline
 
Join Date: Jun 2002
Posts: 430
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hi sde thanks i already use that method above

but its a problem because many softwares like norton and loads of others block http referer so they wont get the variable i have if they came from showpost

anyway thanks very much for the help it looks like im back to the drawing board
Reply With Quote
  #6  
Old 01-23-2006, 07:44 PM
sde sde is offline
 
Join Date: May 2002
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

session does seems like the answer then. you will at least know the user has visited the required page at least once during the session before launching the template.
Reply With Quote
  #7  
Old 01-28-2006, 12:21 PM
Mickie D Mickie D is offline
 
Join Date: Jun 2002
Posts: 430
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sorry to bring this back up again but i had some ideas about sessions

just to clarify can that session code you posted above be used between to different php pages (non vb to vbpages)

thanks very much would be great if i could trace between pages where the user has been

Regards
Mickie D
Reply With Quote
  #8  
Old 01-28-2006, 03:53 PM
sde sde is offline
 
Join Date: May 2002
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

maybe something like this would work:
PHP Code:
<?
// check if the current page is in the session array
if ( !in_array($_SERVER['SCRIPT_NAME'], $_SESSION['visited_pages']) ) {
  // if not, add it
  $_SESSION['visited_pages'][] = $_SERVER['SCRIPT_NAME'];
}
?>
so then to check if a user has visited a certain page, you could do this:
PHP Code:
<?
if ( in_array("somepage.php", $_SESSION['visited_pages']) ) {
  // user has visited somepage.php
} else {
  // user has not visited somepage.php
?>
keep in mind that $_SERVER['SCRIPT_NAME'] does not include the query variables. if you want to count the same php script with different query variables as different pages, then you should use $_SERVER['REQUEST_URI'] instead.

for example, with SCRIPT_NAME, these pages would all be the same:
/mypage.php?a=1
/mypage.php?a=52

REQUEST_URI includes the query variable in the value.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:35 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05599 seconds
  • Memory Usage 2,234KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete