vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Setting a cookie? (https://vborg.vbsupport.ru/showthread.php?t=44188)

bigtime 10-02-2002 04:36 AM

Setting a cookie?
 
Where do I place my setcookie code if I want to set a cookie when someone visits the index page?

I'm having problems with header already being sent errors, so I'm obviously placing my code in the wrong place.

Please help!

Logician 10-02-2002 08:32 AM

cookies should be set before your server send any other info to the user's browser. So if you start sending ANY INFO, say any text, just a letter, even a space char. etc.) before setting your cookie you'll get this message.

This rules still applies when you have inclusions in your code. So you code might not be sending an info to the user but another script included in it may do so, which will cause the same error.

Another frequent mistake is to miss an invisible char somewhere before setcookie command which will again give you the headache (Even if its invisible its a char).

So the solution is to set the cookie before sending any other info to the user..

bigtime 10-02-2002 12:23 PM

Thanks for your reply. I understand the part about setting the cookie before any output, I just really can't figure out where the setcookie code should be inserted. I've tried many different files but I still get the error. What file and line should it be inserted on?

Thanks!

Logician 10-02-2002 04:43 PM

himm.. I thought you know the basics of cookie setting so didnt think you are asking the file name..

Well, for your site's main page, it's index.php and you can use the very top of the file to enter your cookie command.

But considering the fact that you dont know which file you should use, I doubt if you can handle setting a cookie within this file. If you plan to copy/paste from vb file, it wouldnt work as you expected..


All times are GMT. The time now is 02:29 AM.

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.01008 seconds
  • Memory Usage 1,705KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete