Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Passng SID in the URL

Posted on 2004-04-05
5
Medium Priority
?
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

650 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