Jump to content


Photo

Sessions and Refreshing


  • Please log in to reply
3 replies to this topic

#1 Hardbyte

Hardbyte
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationMidlands, UK

Posted 17 May 2006 - 07:44 PM

Hi-ya.

Iv got this admin system and depending on what button(which directs you to a page) you press, it saves a session of that page name. This session only appears to "update" and be stored when I refresh the page for a second time.

Iv tried using the "header("Location: ..." however I get errors as the header is already being used by another script somewhere.

Any ideas on how to refresh the whole page when Iv pressed the button that stores the session page name?

Hope someone can understand the above lol, Its been difficult trying to explain what the issue is.

Thanks in advance.

Hardbyte

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 17 May 2006 - 11:09 PM

Nothing is to be outputted to the browser before a header command, that is a message, space, linebreak etc anywhere in the script or in included scripts before the header call is made. Example if you put the php start tag on line two in a script, this is enough to fail headers. This is a very common issue and there is a pinned post on this issue [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=63200\" target=\"_blank\"]HERE !![/a].
I would say that good practice is to always do the php start tag in the absolute top left corner on any php script you write.

As an alternative to header you can use
<meta http-equiv="refresh" content="{$time}; url={$target}" />
where time is in seconds, set it at 0 and it's instant redirect.

#3 Hardbyte

Hardbyte
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationMidlands, UK

Posted 19 May 2006 - 11:02 AM

Hi - Thanks for the reply. Iv read the articles you mentioned but Im still not getting anywhere.

Iv got includes and headers. In the header its already setting a session of the login.
Now, for example: when button1 is pressed its stores button1 as the value in a new session. If button2 is pressed, button2 is stored in that session instead.

But these only work when the page is "Ctrl + F5" refreshed after the button is pressed. So like it needs refreshing before it works?

Does that make any sense to anyone? I either need to refresh the whole pages including headers when the button is pressed, or header: location needs to work - but it wont as it says is already being sent??!


Thanks in advance.

Hardbyte

#4 Hardbyte

Hardbyte
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationMidlands, UK

Posted 19 May 2006 - 11:20 PM

Bump?

Anyone shed any light on this? Was trying to wash my hands of it over the weekend?

Thanks for any advice.


Hardbyte




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users