Jump to content

Sessions and Refreshing


Hardbyte

Recommended Posts

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
Link to comment
Share on other sites

Nothing is to be outputted to the browser before a header command, that is a message, space, linebreak etc [i]anywhere[/i] 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 [u]always[/u] 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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.