Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-10-2007, 08:28 AM   #1 (permalink)
epochonaut
Junior Member
 
Join Date: Dec 2006
Posts: 7
Default redirect without destroying the session

I've created a form that allows registered members of my site to update their public profiles (address, email, biography, personal interests, etc). The form's ACTION attribute is "updateProfile.php" which contains the code:

<?
session_start();
(database is opened, updated with the new information and closed)
?>

<HTML>
<HEAD>
<TITLE>Update Profile</TITLE>
</HEAD>

<BODY>
<H1>Update Completed!</H1>
<A HREF="file_path">Return</A>
</BODY>
</HTML>

This works fine. The Return link takes me back to the form without destroying the session. But when I try automatically redirecting the page the session is destroyed and I have to log in again. I've used two methods of redirecting; the PHP approach:
<? header( 'Location: page_url' ); ?>

and the javascript approach:

window.onLoad = function() {
window.location="page_url";
}

How can I redirect without destroying the session? (and preferably without having to use cookies?)
epochonaut is offline   Reply With Quote
Sponsored Links
Old 01-11-2007, 01:04 PM   #2 (permalink)
alhefner
Junior Member
 
Join Date: Dec 2006
Posts: 13
Default Re: redirect without destroying the session

I use the header("Location: url") method of redirect often in my scripts and my session isn't lost.

Are you sure that the destination page is php with session_start() at the top of the script? If so, your session should stay intact. Session_start() doesn't always start a new session, if a session already exists for that user, it simply resumes the session.

Al
__________________
www.netmorale.com
Search engine with a twist!
alhefner is offline   Reply With Quote
Old 01-11-2007, 07:12 PM   #3 (permalink)
epochonaut
Junior Member
 
Join Date: Dec 2006
Posts: 7
Default Re: redirect without destroying the session

Yeah, I checked that over a few times. I found a work-around though. I created an empty form on the second page like this:

<FORM METHOD="POST" ACTION="previousPage.php"></FORM>

and used the onLoad event to call the forms submit() event. Unconventional but it works.
epochonaut is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 03:55 AM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums