Jump to content

Using $_SESSION


Kulak

Recommended Posts

Hi,

I have included some variables in my code that I want to be passed from page to page, I wrote the code and everything seemed to be working until I tried my pages from my workplace and discovered that the values weren't being passed. I tried lowering the internet security and allowing cookies and it was fixed.

How do I write my code so that all ie sessions will allow the values to be retained?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/41839-using-_session/
Share on other sites

You can pass values through hidden forms, that might be easier.

 

If you are trying to store a value in a session, remember that you must call session_start() at the top of each script or the session will die. Here is an example of setting a session.

 

$_SESSION['whatever'] = 10;

 

Is that how you are doing it?

Link to comment
https://forums.phpfreaks.com/topic/41839-using-_session/#findComment-202894
Share on other sites

Do you have a submit buttion? If you do you could make your script look something like this:

 

<?php

print<<<HERE

<form action="wherever.php" method="POST">

//Hidden field that contains the value of $value
<input type = "hidden" name="hidden_value" value="$value">

<input type="submit" name="submit">

</form>

HERE;

?>

 

Then to get the value of the hidden field on your next page, just call it like this:

 

$value = $_POST['hidden_value'];

Link to comment
https://forums.phpfreaks.com/topic/41839-using-_session/#findComment-202903
Share on other sites

By default, I believe PHP passes the session id as a cookie (your problem) but then tries to pass the session id in the URL if cookies are not enabled. Not sure why it wouldn't work, but you might want to check your server's php.ini config file to see if for some reason only cookie based session handling is being supported. Maybe you can enable session handling through the URL.

Link to comment
https://forums.phpfreaks.com/topic/41839-using-_session/#findComment-202979
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.