M
M
Makfroy2016-06-20 07:36:29
MySQL
Makfroy, 2016-06-20 07:36:29

Need help with recording session on link click in Zend Framework 1.12.17, how?

There is a database of MySQL cities and two .phtml pages, layout.phtml and index.phtml , I displayed the cities on the city selection page - index.phtml :

<?php
foreach($this->contentRows as $city){
  if(!empty($city->link)){
    $link = $city->id_record .'-'.$city->link;
  }
  else{
    $link = $city->id_record;
  };
  ?>

<a href='/?city'><?=$city->title;?></a><br>
  <?
};
?>

The session starts from the main layout.phtml file :
<?php
  session_start();

    ini_set('session.gc_maxlifetime', 3600*24*30);
    ini_set('session.cookie_lifetime', 3600*24*30);

  if(!$_SESSION['locality'])
  {
     
    if (isset($_GET['city'])){$_SESSION['locality'] = ...;}
        elseif (isset($_GET['city'])){$_SESSION['locality'] = ...;}

It is necessary that when you click on the link a href , the data from the title is written to the session. Tell me please ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2016-06-20
@4Geka

The easiest way is to add one more parameter to the link
And than

if (! empty($_GET['title'])) {
 ...
}

But in general all this code alarms me.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question