sri
sri

Reputation: 121

issues with sending php variable to another page

Is there any other way of sending variables from one page to another without using get, post, cookie, or session?

I'm using header redirect, so I can't use get or post and I'm not able to set cookie, so I can't use setcookie. session is working, but I don't want to use session for some other reasons.

Is there any other way to send variables?

Upvotes: 1

Views: 1051

Answers (4)

Thirumalai murugan
Thirumalai murugan

Reputation: 5914

You can use session and getmethod to send the value

Get method

header("location:update_profile.php?variable=value")

and get it another page as

<?php echo $_GET['variable']; ?>

Setting session

<?php 
   session_start();
   $_SESSION['variable']='value';
   header("location:update_profile.php");
?>

Getting value

<?php
    session_start();
    $value=$_SESSION['variable'];
?>

Upvotes: 0

hek2mgl
hek2mgl

Reputation: 158280

i'm using header redirect, so cant use get ...

Of course you can. Use:

header('Location: test.php?foo=bar');

to send the var foo across HTTP redirect as a GET parameter

Also note that a cookie will still be valid after redirect, if:

  • it is a domain cookie and you are redirecting within the same domain
  • it is a path cookie and you are redirecting withing the same path

Upvotes: 2

Dinesh
Dinesh

Reputation: 447

you can use as....

header("location:update_profile.php?msg=record updated")

and get it another page as

<?php echo $_GET['msg']; ?>

or u can use link as

<a href='yoursite.php?user=anything......'>click</a>

and retrieve it via Get[]

Upvotes: 0

Piotr Kowalski
Piotr Kowalski

Reputation: 338

maybe this below HTML5 feature will help you, I mean: sessionStorage http://www.w3schools.com/html/html5_webstorage.asp

Tell me if it's what you were looking for.

Upvotes: 0

Related Questions