The question is basically this, I have seen on many sites a session like &ses=1234567… that is, a session consisting of numbers. I tried to do something like this, but it didn’t work! I would like to know how to implement this?
Answer 1, authority 100%
It’s not entirely clear what exactly you can’t implement: how to work with a session containing a certain name, or generate random numbers. Well here’s an example that at least creates a variable and a link to a page with &ses=1234567
<?php session_start(); $_SESSION['ses'] = rand(1000000, 9999999); echo "<a href=\"somepage.php?someresult=true&ses=" . $_SESSION['ses'] . "\">Link</a>"; ?>
Specify what exactly you expect from &ses=1234567, for what purpose are you implementing it?
Answer 2, authority 50%
As far as I can see, this is not a session, but passing variables using the GET method. Example in PHP
<?php <form action="some_site.php" method="GET" name="form1" target="_blank"> <p><input name="name" type="text" size="20"></p> <p><input name="lastname" type="text" size="20"></p> <!-- --> <p><input name="submit" type="submit" value=""></p> </form> ?>
The line will appear like
some_site.php?name=Jack&lastname=Dou&submit=%CF%E5%F0%E5%E4%E0%F2%FC. I hope it’s understandable. You can read the data via
<?php $name = $_GET['name']; $lastname = $_GET['lastname']; echo ' '.$name.' '.$lastname; ?>
Naturally, you can enter both numbers and words.
The task of the session is to form a unique sequence, the algorithm used when calling a regular session guarantees this. There is no dance with rand().
In the PHP settings, you can select the encryption algorithm and key length. You won’t be able to use numbers only by standard means!
read about hex :))) You can put any string in there….. and kick it out 😀