Solved

Passng SID in the URL

Posted on 2004-04-05
5
171 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

920 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