Solved

Passng SID in the URL

Posted on 2004-04-05
5
170 Views
Last Modified: 2006-11-17
How do you pass the 'same' Session ID number from one page to another when using forms several times on consecutive pages?

I have no problem passing the SID using a href link from page to page.

I have no problem passing the SID from the 'first page' when submitting a form as below:

      if (isset($_POST['submit']))
      {
            
            header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF'])."/example_page.php?". SID );
            exit();
      }

But when I come to use another form on another page a new SID is passed and my orginal one is lost when the form is  submitted and all my variables are lost?????

I hope this makes sense.

Would be grateful for your help,

Beam.
0
Comment
Question by:Beam
5 Comments
 
LVL 6

Expert Comment

by:CosminB
ID: 10757618
send it in a hidden field:
try this:
echo '<input type="hidden" name="',session_name(),'" value="',session_id,'">';
0
 
LVL 2

Expert Comment

by:ElForesto
ID: 10761261
I would imagine that the session would be set server-side, so you shouldn't have to do much beyond session_start() and setting the session variables. Have you tried this scenario? It should be pretty much transparent.
0
 

Author Comment

by:Beam
ID: 10764367
I have just worked it out and thought you guys might want to know for future reference. Basically when you validate a form you post back to it's self, when the submit button is pressed. Please see example below:

<form action="<?php echo $SERVER['PHP_SELF'] ?>" method="post">

But when passing SID through the URL every single link has to pass it otherwise a new SID is produced. I forgot that my forms posted to them selves for validation reasons. I changed the code above to this:

<form action="<?php echo $_SERVER['PHP_SELF']."?". SID  ?>" method="post">

Now the session_id is the same for every page.

Thank you for your time.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12685500
PAQed with points refunded (250)

modulo
Community Support Moderator
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now