Solved

Passng SID in the URL

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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.

815 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

12 Experts available now in Live!

Get 1:1 Help Now