how can i pass variable on a link ?

i have one links, from that user can access one of secure page...
but i want to check first, if user is already logged in, then only he can access page otherwise, he directly go to login.php from that links.
Who is Participating?
Then you should use sessions instead of variables on a link.

See for a session tutorial

or for an authentication tutorial with cookies... as you wish !
<a href="file.php?var1=data1&var2=data2&var3=data3">link stuff</a>

data retrieval:

You can add as many as you like, just keep adding a & sign in the link with 'variable name' = 'data'.

To retrieve it, you just use the $_GET environmental variable.

You can then work with those variables however you like... compare them against a database or something hard coded into the PHP file to authenticate.

hope that helps,
Hi kohashi,

 I think we can't pass with URL more than 256K of data..
' don't say as many as he wants'..

 The above one works fine..

with regards
I dont know about you but, its pretty hard to make a url with 256k worth of data, by hard i mean, you would never end up storing that much in an address bar.

But i think sessions is a better idea if you are worried about security.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.